Goal: Automate payment reminder emails at multiple intervals and send them to custom B2B recipients stored in Company Location metafields, not just the main contact.
Issue: Using the âPayment schedule is dueâ trigger led to a failure in âSend order invoiceâ with error âorder_id is required but empty.â Screenshots of the workflow and error were provided.
Root cause: The trigger doesnât expose an order directly. The action was pulling context from the metafield owner (a location), not an orderâpossibly a bug.
Fixes/Guidance:
Reference the order via paymentSchedule.paymentTerms.order.id (add as a variable).
You cannot force âSend order invoiceâ to use a different ID; it auto-assigns from context. Adjust preceding steps instead.
Remove the For Each loop. Fetch each recipient using âmetafield (requires arguments)â for specific keys (e.g., email1, email2, email3).
Recipient Liquid path shared by OP appears correct (e.g., âŚpurchasingEntity.PurchasingCompany.location.invoiceRecipient1.value).
Note: A condition checking if a metafield key exists doesnât select that value for subsequent actions.
Status: User acknowledged the guidance; approach appears workable. No explicit final confirmation, discussion likely near resolution.
Summarized with AI on December 14.
AI used: gpt-5.
The problem with the payment reminders standard Flow is that it just sends to the main contact of B2B companies, and although you can customise the invoice Flow to add a custom message, a Flow that starts with the âPayment schedule is dueâ trigger then fails as it cannot find the correct order (âRan into exception: Fields: order_id are required but are emptyâ).
You donât have an âorderâ available from the trigger. The action is actually using the order attached to the metafield owner, which might be a bug, because I donât think that owner is actually an order in this case but a location.
Probably the path to the order is payment schedule / paymentTerms / order / id (click âAdd a variableâ to insert it).
I think your logic has issues as well but hopefully that helps you test a bit.
Thanks Paul, do you know how I would force the Send order invoice action to use the order from that path (payment schedule / paymentTerms / order / id)? At the moment it seems to be fixed on the For each loop and takes the information from that, and thereâs no way within the Send order invoice action to select the order path
I would remove that For-Each path entirely and instead just get each of the 3 metafield values directly (no looping). Choose âmetafield (requires arguments)â instead of metafields.
You cannot currently force an action to use a different ID as itâs auto-assigned. But changing that data is has access to should work
So I will remove the For each loop and just change it to Check if metafields key is email1 like this, and now the Send order invoice window looks like this. Do you think that will work now?
That condition just checks if that key exists in the list of metafields. It doesnât select it for subsequent actions. Iâd expect that itâs always true, unless you have locations that do not have an email1. But the liquid you posted previously looks correct.