Table of content:
Introduction
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 Settings 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.
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.
Endpoint | Method | Description |
|
| 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. |
The Concept
When the synchronization is turned on the following will happen:
a scheduled job named
SalesWings Studio : Watcher
will be immediately created.SalesWing Studio : Watcher
will 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 classWorkflowSchedulable
will 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
SWJob
as a prefix.The
SWJobFinalizer
is responsible for resetting the sync cycle internal state if necessary (e.g. disabling the full sync option previously enabled). It also collects and send metrics to provide key information on successes/errors tracked during the sync cycle.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 theSync Gap (mins.)
field in theSW Studio Options
custom settings). It will scheduled a job namedSalesWings Studio : Runner
(this requires an additional, but temporary, scheduled job slot).After the given number of minutes
SalesWings Studio : Runner
executes 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 Threshold
field 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.
To examine such results in a friendly way please use the Status section of SW Settings page.
The Statuses
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 aFailed
status).Partially_Completed
: the synchronization completed but some steps either completed partially or outright failed.Completed
: the synchronization completed successfully (all the steps registered aCompleted
status).
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:
Type | View Name | Filters | Description |
Apex Jobs | SW Studio All |
| Contains all the jobs created by the solution: batches, queueable, triggers |
Apex Jobs | SW Studio Steps |
| Contains only the jobs that correspond to each synchronization step |
Scheduled Jobs | SW Studio |
| 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.