Skip to main content

Post Sync Scripts

Overview

Post sync scripts are written in CQL and can be added to the end of a sync to allow you to do more with your data, such as inserted retrieved values into a Cinchy table.

Parameters

For real time syncs that have a Cinchy Table as the target, @InsertedRecordIds() and @UpdatedRecordIds() can be used in post sync scripts to narrow the scope of an update to the Cinchy Ids of the records that were inserted or updated by the event. These functions accept the values as a comma separated list, to be used in an IN clause.

Example:

(
[Cinchy Id] IN (@InsertedRecordIds())
OR
[Cinchy Id] IN (@UpdatedRecordIds())
)

Example

This example takes you through a batch data sync using the Cinchy Table [Product].[Names Test]. This scenario uses the following API as the destination: https://cinchy.net/API/Product/LatestCinchyReleaseDate

When you run the batch job, it will check for updates in the source table. These updates trigger the REST API to fetch our defined value, which we can use in a post-sync script. In this example, the script will insert this value into a second table, [Product].[Response Table].

The following steps will walk you through how to use this functionality.

  1. Set up your data sync to a REST API. You can review the Source, Destination, and Sync Behaviour.

Post Sync Scripts

  1. Under the Post Sync tab, input the CQL that takes the defined variable from the REST API and insert it into the [Product].[Response Test] table.

  2. Add in your Permissions and click Save.

  3. After you configure the sync, run the job. It will check for new data in the Name column on the [Product].[Names] table. When found, it will trigger the REST API to GET the “value” variable. The post sync script will take that value and INSERT it into the [Product].[Response Test] table.

Image 6: Post Sync Scripts