Table of content:
To keep data synchronized and consistent SalesWings Studio makes use of scheduled and asynchronous jobs that run regularly. Knowing how all this works is key to understanding how the Salesforce platform is engaged at any given time.
Turning The Sync On or Off
The synchronization should be turned on or off from the SalesWings Setup page alone. For argument’s sake, although Salesforce gives a possibility to abort both scheduled and async jobs from the Scheduled Jobs and Apex Jobs pages respectively that is not recommended as there might be more than 1 job scheduled or queued at a given time. Turning the sync off from the Setup page will take care of all of them at once.
Synchronization turned off
Synchronization turned on
Sync Commands Via REST API Call
An additional method, via REST API, is provided to turn the sync on or off. It can also be used to return the sync status.
By means of a JSON object it returns the status of the sync:
It will turn the sync off and on.
If the sync is detected to be already running the call will return a
If the call is successful a the sync status JSON representation is returned.
When the synchronization is turned on the following will happen:
a scheduled job named
SalesWings Studio : Watcherwill be immediately created.
SalesWing Studio : Watcherwill execute 1 minute after the synchronization was turned on, and subsequently every hour (this means that 1 scheduled job slot will be permanently occupied by it). Its execution will trigger (a job associated with the class
WorkflowSchedulablewill appear in the Apex Jobs page) the synchronization cycle made up of different workflow steps.
Each workflow step runs as independent Apex Job associated with a class having
SWJobas a prefix.
The last job, named
SWJobEnqueuer, wraps up the cycle and schedules the next execution to run after a certain number of minutes, as defined in the
Sync Gap (mins.)field in the SW Studio Options Custom Settings. It will scheduled a job named
SalesWings Studio : Runner(this requires an additional, but temporary, scheduled job slot).
After the given number of minutes
SalesWings Studio : Runnerexecutes and step 3 is repeated.
The Concept Visualized
More on SalesWings Studio : Watcher
This scheduled job is tasked with multiple responsibilities:
Kicking off the sync the first time it’s scheduled
Deleting any number of SW Apex Job records that exceeds the maximum number as defined in the
Apex Jobs Number Thresholdfield of SW Studio Options Custom Settings.
Restarting the sync if, for some reason, it failed to re-enqueue itself.
Notifying users if the sync hasn’t run in a certain amount of time as per rules defined by the SW Studio Notification Settings Custom Settings
Keeping Track on the sync
For every synchronization cycle a corresponding
SW Apex Job record gets created. The record keeps track of synchronization start and end time as well as of its status. It also provide a text area field in which specific workflow step information are kept and saved in a JSON format.
By accessing the SW Apex Job list view is possible to have an immediate feedback of the synchronization cycles and the status of their completion.
List of SW Apex Job record. Each record represents 1 synchronization cycle
The detail page provides access to the text area field with the step information in their JSON representation.
SW Apex Job Detail page
To the overall synchronization, one of the following statuses can be assigned:
Queued: the synchronization will begin shortly.
Processing: the synchronization process has started.
Failed: the synchronization failed (all the steps registered a
Partially_Completed: the synchronization completed but some steps either completed partially or outright failed.
Completed: the synchronization completed successfully (all the steps registered a
To the individual step, one of the following status can be assigned:
Queued: the step will soon be processed.
Processing: the step is being processed.
Failed: the step either encountered an irrecoverable error or all the batches (if applicable) returned errors.
Partially_Completed: the step processing completed but some batches (if applicable) failed.
Completed: the step completed successfully without reporting any error.
Isolating the Jobs
To better isolate SalesWings jobs from the others running in the organization create a view and use the following filters:
SW Studio All
Contains all the jobs created by the solution: batches, queueable, triggers
SW Studio Steps
Contains only the jobs that correspond to each synchronization step
Contains all the scheduled jobs created by the solution
Example of Apex Jobs SW Studio Steps view
Number of SW Apex Job Records
The number of
SW Apex Job records kept is determined by the value for
Apex Jobs Number Threshold field in the SW Studio Options Custom Settings.