function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RiellRiell 

Syncing products to an external system

I'm syncing product data from salesforce to an external system using the salesforce API. The problem I'm having is determining if pricebookentry records have been updated in SF. Here's what I'm doing:

 

I have a custom field on the product table called syncDate__c that I write to when I've sync'd a product to my system.

I have a custom formula field on the product table called needsSync__c that gets set to 1 if the lastModifiedDate is more recent than the syncDate__c, otherwise it's set to 0.

That all works great, and makes it easy to fetch updated products doing something like: select id, name, etc from product2 where needsSync__c = 1.

 

The problem I'm running into is knowing when to fetch updated pricing info. I can't figure out how to compare the lastmodifeddate from pricebookentry with a date on the corresponding product.

 

How can I determine if a pricebookentry has been updated more recently than the product it references without fetching all pricebookentry and product2 records?

 

 

 

 

 

sfdcfoxsfdcfox

Why not use the Replication API? Using getUpdated and getDeleted on Product2 and PricebookEntry should return all the results you need without the mess of tracking "needsSync__c".