Document Posted
Use the Document Posted trigger to run a flow interactively — in your own session, at the moment a user posts a document — for Sales and Purchase documents. Because it runs synchronously, just before the posting, the flow can:
- Prevent the posting. End the flow with an Error step and the posting is cancelled with your message. Ideal for enforcing extra requirements ("a cost center is required before posting").
- Adjust the document first. End the flow with a Set document field values step and your values are written onto the header before it is posted.
Any other AutoFlow step can be used in between (look something up, call a service, and so on).
Supported documents (pick exactly one table):
- Sales Header
- Purchase Header
Typical examples:
- Block posting a sales invoice until an external document number is filled in.
- Require a dimension value on purchase invoices before posting.
- Default a responsible person onto the document as it is posted.
What happens when the flow runs
- A user posts a Sales or Purchase document from the page.
- AutoFlow applies your field filters. If the document does not match, the posting proceeds normally.
- The flow runs to the end, synchronously, before the document is posted:
- If it ends with an Error step (or any step raises an error), the posting is cancelled and the user sees the message; nothing is posted.
- If it ends with a Set document field values step, those values are written onto the document and the posting continues.
- If it just ends, the posting continues unchanged.
Preview Posting does not fire this trigger — it only runs for a real posting.
Trigger output
Rec— a reference to the document being posted, so SmartFields can read its fields (e.g.{{<slug>.Rec.Amount}}) and follow-up steps can use it.
Configure the trigger
Open the flow editor, pick When a document is posted (interactive), and complete the card.
Table
Choose Sales Header or Purchase Header.
Interactive sessions only
Leave this on (the default) so the flow runs only when a person posts the document in the client.
Timeout (seconds)
The flow runs while the user posts the document, so keep this short.
Field Filters
Optional. Limit the flow to documents that match certain criteria (for example Document Type = Invoice).
Change the document: Set document field values
To adjust the document before it is posted, end the flow with the Set document field values step (available in Document Posted flows). Add a row per field, type a value (SmartField references supported), and choose Validate (as if typed on the page) or Assign (raw value).
Prevent the posting
To stop the posting, end the flow with an Error step and supply the message the user should see. Nothing is posted.
Show a message on the page
Add a Send Notification step to surface a message to the user as a page notification without stopping the posting. The step is only available in the interactive document triggers.
Document Released vs Document Posted
These are complementary. The Document Released trigger intercepts the release of a document; the Document Posted trigger intercepts the posting. Both hook the operation itself and can cleanly prevent it, so use whichever matches the step in the document lifecycle you want to guard. For direct field edits, use the Document Modified trigger instead.