Sometimes it is required to get last run date and time of the scheduled integration to avoid the duplicate processing of data.
This is possible in the Scheduled Integration type. This can be achieved using creating parameters in Scheduled Integration.
We can create and update scalar type parameters in scheduled integrations that determine how to batch and read data received from a source location. We then use these parameter values downstream in the integration. We create and assign values to these parameters in the Schedule Parameters page that is available in scheduled orchestrated integrations. We can also assign values to these parameters in assign actions. Up to five parameters are supported in the Schedule Parameters page.
Let’s see how to get last run date and time.
- Login into ICS console
- Click on Integrations tile from home page
- Click on Create button from upper right side corner
- Select the Orchestration pattern
- For the What triggers this integration option, select Schedule and click Create button
- Click on Scheduled icon, then select Edit
- In the Parameter Name column, click the plus icon
- Enter a name(LastRun), an optional description, and a default value in the Value column
- Click Close to save the changes and exit the page. A red warning icon is displayed on the Schedule icon. If we place the cursor over the icon, a message indicates that one or more parameters are missing a value
- From the Actions section, drag an Assign activity into the integration, enter a name, and then click OK.
- In the Name column, click the plus icon, then select the parameter from the dropdown list that we created in the Schedule Parameters page
- Click the Edit icon to invoke the Expression Builder and drag the startTime into the Expression box, then close button
- Drop Logger action between Scheduled and Assign Activity. Give Name and optionally Description, then Create
- Select Always Radio button, click on Edit Expression icon, and add the below expression:
concat(‘Previous date and time ‘ ,$LastRun)
- To complete the integration, add any Invoke activity as the mandatory step.
Let’s Activate the integration and Submit the integration. Open the Monitoring Dashboard and see the instance Activity Stream
Note: First time the last run date will come null.
Let’s submit the integration again and see what previous date & time comes
See the previous date & time is 2017-10-20T09:46:56.238+00:00. This is the time of the previous run itself.