Update custom property on Shipment and evict from cache

Vote:
 

Hi Guys,

We have a scheduled job running every 10 minutes that exports shipments for Purchase orders based on different criteria.  One of the main criteria is a flag we set on the shipment via a custom property.  Once the shipment is processed and exported, we set the flag.  What we are finding is that occasionally shipments are included more than once.  The job normally completes within a few seconds.

I'm using the OrderContext to retrieve PurchaseOrders and subsequent Shipments.  I'm updating the flag on the Shipment via AcceptChanges.  Just wondering if there is caching in play here and if there is a better way via the API to retrieve and update.  Would updating the shipment in this way evict the PurchaseOrder from cache so when retrieving the PurchaseOrder the next time the updated shipment would be included?

var poList = OrderContext.Current.Search<PurchaseOrder>(searchParams, new OrderSearchOptions
{
    CacheResults = false,
    StartingRecord = 0,
    Namespace = "Mediachase.Commerce.Orders"
});



Shipment.SetMetaField(Global.Metadata.Shipment.Export, true);
Shipment.AcceptChanges();

Cheers
Mark

#216549
Feb 10, 2020 2:48
Vote:
 

The cache is on order level. You should call order.AcceptChanges instead. 

#216569
Feb 10, 2020 9:24
Vote:
 

Thanks Quan, I expected that.

#216609
Feb 11, 2020 2:56
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.