After Sync Trigger
Pulsar currently supports running custom Pulsar Settings Language upon completion of a sync. This can be useful for recording the sync time, counting records, or alerting the user to new information. NOTE: This trigger is tied to sync, and any data changes during this setting execution will be pushed to the Salesforce server, even if the user is forced offline permanently via settings.
If you are using forced offline permanently setting, you may want to use the following actions to send the sync stats to Salesforce. NOTE: The SFCreate and SFUpdate PSL actions push changes directly to Salesforce and will NOT update the local Pulsar database. Any creates and updates using these actions will need to be synced to Pulsar at a later time. Otherwise, you can use these PSL actions that write to the local database as well. |
When using SFCreate or SFUpdate to write to an object, make sure that the object is included in the list of objects to sync or is specified it in the relationship directives setting. Pulsar needs the schema information in order to write to objects. If the user does not need access to the records in the object, then they do not need to download the record data. Add a sync filter (Id = null) on that object to prevent the data from downloading.
Here is a trivial example that displays the sync date/time upon a successful sync:
Name: After Sync Trigger
Key: pulsar.sync.AfterSyncTrigger
Value: Pulsar Settings Language
DEFAULT{
Action=SetVar;
VarName=LastSync;
VarValue=@@LastSyncTime;
|
Action=Alert;
Message=Last successful sync time: %%LastSync%%;
} |
Here is a bit more complicated example that updates the user record with sync details on a successful sync, and creates an error record and attaches logs if the sync fails:
DEFAULT{
Action=SetVar;
VarName=LastSync;
VarValue=@@LastSyncTime;
|
Action=SetVar;
VarName=CurrentUserId;
VarValue=@@CurrentUserId;
|
Action=SetVar;
VarName=AppVersion;
VarValue=@@AppVersion;
|
Action=SetVar;
VarName=LastSyncSuccess;
VarValue=@@LastSyncSuccess;
|
Action=SqlQuery;
QueryString=SELECT CASE WHEN '%%LastSyncSuccess%%' = 'TRUE' THEN 1 ELSE 0 END AS SyncSuccess;
QueryReturnFields=SyncSuccess;
QueryTest=%%SyncSuccess%%=1;
QueryTestTrue=UpdateUser;
QueryTestFalse=CreateError;
}
UpdateUser{
Action=SFUpdate;
ObjectType=User;
Id=%%CurrentUserId%%;
LastSuccessfulPulsarSync__c=%%LastSync%%;
}
CreateError{
Action=SFCreate;
ObjectType=Sync_Error__c;
AffectedUser=%%CurrentUserId%%;
AppVersion__c=%%AppVersion%%;
SyncFailureDateTime__c=%%LastSync%%;
AttachLogFile=TRUE;
} |
Full List of Sync Stat Values
@@AppVersion
@@PreviousSyncTime
@@LastSyncSuccess
@@LastSyncTime
@@LastSyncDuration
@@LastFailedSyncTime
@@LastFailedSyncDuration
@@LastFailedSyncErrorCode
@@LastFailedSyncCurlErrorCode
@@LastFailedSyncCurlErrorMessage
@@LastFailedSyncSfErrorCode
@@LastFailedSyncSfErrorMessage
@@LastFailedSyncHttpResponseCode
@@LocalCreatedCount
@@LocalDeletedCount
@@LocalUpdatedCount
@@LocalUpdatedUniqueCount
@@ServerProcessedCount
@@ServerProcessedObjectCountMap
@@ServerIntegratedCount
@@SyncDomainType
@@SyncWindowType
@@SyncResumed
@@SyncPassCount
@@SchemaChanged
@@SyncGeneration
@@MetadataSyncPerformed
@@MetadataSyncDuration
@@ReachabilitySyncPerformed
@@ReachabilitySyncDuration
@@RefreshPerformed
@@RefreshDuration
Visit the following related pages for more information about this topic: