Schedule Later step
Run the rest of a Glue job, or another job, up to 30 days later.
The Schedule Later step runs something after a delay of up to 30 days. It can pause the rest of this job and pick it up later, or queue another job to run later while this one carries on.
For a short pause of a few seconds within the same run, use Wait instead.
Set it up
| In the app | data field | What it does |
|---|---|---|
| Amount | amount | A number greater than 0. Liquid works, so a script can work it out. |
| Unit | unit | Seconds, Minutes (the default), Hours or Days. |
| What runs later | target | Rest of this job (the default) or Another job. |
| Job | job | Another job only: the job to queue, by ID or exact name. |
| Payload (optional) | payload | Another job only: sent to that job as its default variable. |
| Response variable | response_variable | Saves scheduled_at, plus job_id when another job is queued. |
The total delay can be at most 30 days. Anything longer fails the step.
Rest of this job
The run stops at this step, as a success. When the time comes, the job picks up at the next step with the variables it had, so later steps can still use $.sale and everything else you set before the delay.
- It has to be a top-level step. It can't sit inside an If Condition, Loop or Lock. To delay only in some cases, put a Schedule Later set to Another job inside the If Condition instead.
- Variables are carried over, up to 1 MB. If the job's variables are bigger, the step fails with an error saying how big they are and asking you to remove large variables before the delay. Clear big responses you no longer need first, for example
$.products_res = null;. - Save the job first. The step needs to be saved before it can schedule the rest of the job.
Another job
The other job is queued to run after the delay, and this job carries on straight away. The other job gets Payload as its default variable, up to 1 MB.
In a test (when you select Run in the job editor), Schedule Later only logs what it would do. Nothing is scheduled, and with Rest of this job the test stops at this step.
Example 1: Queue a review job for a big sale
Trigger: System Hook, Create Sale.
-
Script: Read the sale
var sale = JSON.parse($.default); $.needs_review = sale.total_price > 2000; $.review_payload = JSON.stringify({ sale_id: sale.id }); -
If Condition: If the sale should be reviewed, Condition
$.needs_review === true. Under THEN:- Schedule Later: Queue the review job, Amount
2, Unit Hours, What runs later Another job, JobReview big sales, Payload{{ review_payload }}.
- Schedule Later: Queue the review job, Amount
Example 2: Email the customer the next day
Trigger: System Hook, Create Sale.
-
Script: Read the sale
var sale = JSON.parse($.default); $.sale_id = sale.id; $.customer_email = (sale.customer && sale.customer.email) || ""; -
Schedule Later: Wait until tomorrow, Amount
1, Unit Days, What runs later Rest of this job. -
If Condition: If the customer has an email, Condition
$.customer_email !== "". -
Email: Email the customer, under THEN.
Keep the variables small before the delay: here the script saves only the sale ID and email, not the whole sale.
Tips
- Check before you act. A day later things may have changed (the sale may have been refunded, say). Look the record up again after the delay if it matters.
- Retries don't schedule twice. A top-level Schedule Later that already worked isn't repeated when the job is retried.
Updated about 23 hours ago
