Polling with last runtime

                                                                                      A lot of service connectors have a 'list records'-type operation which includes the ability to set what date you want to pull records from.

                                                                                      This is very important when you are wanting to periodically pull records in order to update them in some way, or sync to another service.

                                                                                      The workflow below shows how you can set up a polling system using the 'list orders' operation in Shopify (this method could be used in any number of connectors such as Salesforce or Outreach).

                                                                                      This workflow will allow you to only pull the orders that have been made since the last time the workflow was run:

                                                                                      Note that this workflow makes use of Workflow level data storage.

                                                                                      Note that this workflow could be manually triggered as and when you need to use it, or it could use a scheduled trigger.

                                                                                      Important note
                                                                                      Copy

                                                                                      Your schedule should also be set so that you allow plenty of time for runs to complete. In a case where 3 attempts at starting a run are made while one is still completing, these runs are missed. They are not added to a queue.

                                                                                      Step 1 - Get today's date
                                                                                      Copy

                                                                                      The first step uses a Date/Time Helper to get today's date with the Get current timestamp operation:

                                                                                      Step 2 - Get lastruntime
                                                                                      Copy

                                                                                      The second step uses a Data Storage connector Get value operation (workflow level scope) to get the lastruntime key (the name of this key is arbitrary and you can name it whatever you wish):

                                                                                      Step 3 - lastruntime found?
                                                                                      Copy

                                                                                      This step uses a boolean connector to check if lastruntime is not 'null' (i.e. is it the first time the workflow has run?):

                                                                                      False branch - Pull orders first run
                                                                                      Copy

                                                                                      If the boolean returns false this indicates that it is the first time the workflow has run so we grab today's from the date time helper and pass it to the Created at max parameter for the Shopify List Orders operation:

                                                                                      True branch - Pull orders from lastruntime
                                                                                      Copy

                                                                                      If the boolean returns true then we can pull the lastruntime date value from data storage and pass it to the Created at min parameter for the Shopify List Orders operation:

                                                                                      Step 4 - Set lastruntime
                                                                                      Copy

                                                                                      The final step is to take today's date and set it as the lastruntime so it is picked up the next time the workflow is run: