Optimized Data Synchronization with Criteria-Based Sync
You can now enable the criteria-based sync for any entity. Criteria-based sync allows the administrators to decide which records should be synced for an entity. So, there is no need to spend time syncing the customer data, which is not required. The following are the key features available with the criteria-based sync.
- Ability to change the criteria at any time as the changes in filter criteria impact only the jobs that change the expiry date.
- Consumer API does not need to filter the records in their search APIs (Consumers need not worry about the criteria).
Criteria-based sync uses a condition that can be applied on the turboexpirydate__c field for the given Salesforce object. The data sync does not ship the turboexpirydate__c field for the Salesforce objects out of the box, and the consumer has to create this field or populate the required objects based on their filters. The turboexpirydate__c must be created with the same name, and it is case-sensitive. The turboexpirydate__c field should be an object with 'DateTime' and 'Indexed' to pull the records from Salesforce. In addition, the turboexpirydate__c field can have three values Null, Any Future Date, and Any Past Date.
DataSync Runtime would process the pulled records (from Salesforce) in the following manner. Currently, the records have been pulled based on the 'LastModifiedDate' field.
- The record is considered valid and gets synced to the consumer-endpoint if the turboexpirydate__c field value is greater than the sync-cutoff-time.
- The record is considered invalid and gets deleted from the consumer-endpoint (if it exists) if the turboexpirydate__c field value is less than the sync-cutoff-time.
- The record is considered ignored if the turboexpirydate__c field value is Null.
The following table provides a summary of the scenarios to understand the outcome of criteria-based sync quickly.
Scenario |
Criteria-Based Sync Outcome |
---|---|
The value of turboexpirydate__c is null during the earlier DataSync run, but it contains a future date and time for the current run. |
The record gets synced to the consumer endpoint. |
The value of turboexpirydate__c was past-DateTime during the earlier DataSync-Run, but it contains a future-DateTime for the current run. |
The record gets synced to the consumer-endpoint. |
The value of turboexpirydate__c was future-DateTime during the earlier DataSync-Run, but it contains a past date and time for the current run. |
The record gets deleted from the consumer-endpoint. |
The value of turboexpirydate__c was future-DateTime during the earlier DataSync-Run, but it contains null for the current run. |
The record remains unchanged at the consumer-endpoint as data sync stops tracking that record if the turboexpirydate__c has a null value. Ensure that you avoid this kind of scenario as it leads to inconsistent data in the consumer point. |
Enabling criteria-based sync for an SFDC Object:
Assuming that the field turboexpirydate__c has been created and populated with the appropriate values. The following are the four possible use cases while enabling the criteria-based sync for an SFDC object.
Disabling criteria-based sync for an SFDC Object
The following are the two possible use cases while disabling the criteria-based sync.
Implementing Criteria-Based Sync with Apex Jobs
Tenant Admin can exclude the invalid records from sync by setting the past date in the expiry date field. The expiry date is set based on the criteria condition.
- Create a new turboexpirydate__c (case-sensitive) field with the appropriate date in the object on which you want to perform the Criteria-based sync.
- Create a new custom metadata type.
- Create a new Apex class.
- Open the developer tool and execute the following statements.