Schedules, Get Data, and Looping

In most cases, you can build a workflow by linking together multiple conditions and actions to a trigger that runs when an event happens. For some use cases, you might find that no trigger exists for what you need to do, or you need it to run at a certain time, or you may need to work with a list of data.

As an example, suppose that you want to get a daily summary of unfulfilled orders. With this group of features, you can run a workflow that runs every day at a certain time, that gets those orders, and then sends you a summary of them.

In this doc, you will learn about the Scheduled time trigger, the Get data actions, and the For each action. If you're not sure how best to use these features, then you can explore more examples and templates that make use of these triggers and actions, or watch this explainer video.

Scheduled time trigger

Instead of starting a workflow because of an event, the Scheduled time trigger starts a workflow at a specific time and date that you specify. You can also schedule the workflow to recur hourly, daily, weekly, or month. As a result of running from a schedule, to use data like customers, orders, or products, you have to use an action to get that data. You can do this by using Get data actions.

Get data actions

Most actions change something in your store (e.g., adding tags to a customer) or send a command to an app (such as instructing an app to send a push notification to a customer).

Get data actions fetch data from your store for use in Flow. These actions call a query with a set of filters, for example to get only something updated in the last day. The action returns a list of data that match that data. For example, the Get order data action calls the Order query on the Admin API and returns a list of orders that match your query.

The following actions retrieve information from your store so that you can use that data in your workflow. Consult each action for details on how to filter data and what data is returned:

Liquid tags

When using a Get data action with dates, you can use the date_minus and date_plus Liquid tags to change dates in your query. For example to calculate a date 5 days before the scheduled run time of a workflow, you can use the following Liquid:

{{ scheduledAt | date_minus: "5 days" }}

For more details about how to use these tags, refer to the documentation on Liquid variables.

Loops

When you use a Get data action, you get a list of data that matches your query. You can use the For each action to loop through that list. In a For each loop, you can use conditions and actions that will apply to just that item.

For example, you can create a workflow that includes the Get order data action. You can then use the For each action to add a tag to every order.

Example of a workflow retrieves a list of orders every week and adds a tag to each retrieved order.

Aggregation actions

When working with lists, you might want to count the number of items to use in later Conditions and Actions. For example, you might want check if there are more than 0 results before sending an email. Flow provides these actions to perform calculations on list data in a workflow:

  • Count - returns the number of entries in a list
  • Sum - adds together the values of entries in a list

Known limitations

  • The Get data and For each actions can only run on lists up to 100 items long.

In this section

Ready to start selling with Shopify?Try it free