Excluding Updated Service Board Job Records From Real-Time Sync
At times, it can be useful to exclude updated Job records from Salesforce-to-Service Board real-time sync to improve performance. For example, if you implement custom code to set field values in Salesforce Work Order records, and code execution takes place after Process Builders or Flows are triggered, the resulting changes are not synced to Service Board. Therefore, to ensure these new values are properly synchronized, you can create a custom System Job to detect whether this field value is configured in Salesforce Work Order records and empty in the corresponding Job records in Service Board, and to then use a REST call to retrieve the value on the Salesforce side and set the value on the Service Board side. To avoid triggering an HTTP Notification to sync identical field values back to Salesforce, you can follow the steps in this procedure to exclude these updated Job records from real-time sync.
To exclude updated Service Board Job records from real-time sync:
Add the following script before the script that is used to update Job records:
IntegrationUtil.notSyncJobBackToSFDCForCurrentTransaction()
For example, to create a custom operation to update dev_add field values in Job records and prevent real-time sync back to Salesforce, you can create Operation and Source records and implement the following script in the Source records:
package com.servicemax.myapp.operation

import com.servicemax.core.Database
import com.servicemax.core.Max
import com.servicemax.core.MaxObject
import com.servicemax.dc.operation.DCOperation
import com.servicemax.dc.util.IntegrationUtil

class UpdateJobCustomOperation extends DCOperation {

@Override
protected Object realExecute(Map<String, Object> parameters) throws Exception {
Max.executeAsAdmin{
def jobId = 'xxxx'
MaxObject job = Database.querySingleResult("SELECT * FROM svmx_job WHERE io_uuid = ${jobId}");
IntegrationUtil.notSyncJobBackToSFDCForCurrentTransaction()
job.dev_ddd = true;
Database.update(job)
}
return true
}
}
* 
Be aware that if you implement this script in Event Handlers for the Update Job event, Job records also are not synced back to Salesforce, because HTTP Notifications are triggered after the main transaction and all Before and After event handler execution is complete. Therefore, for best results, implement the script in custom System Jobs, custom Operations implemented in Initial Sync Actions or Transform Templates, or as a custom Action Menu option.
For more information:
Was this helpful?