Skip to main content

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 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​

  1. A user posts a Sales or Purchase document from the page.
  2. AutoFlow applies your field filters. If the document does not match, the posting proceeds normally.
  3. 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 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.

The table picker lists every table in the system, but the trigger only works on the tables above. Pick another one and the status line at the bottom of the dialog says so straight away – "Table 17 (G/L Entry) is not supported by this trigger, so the flow would never run" – and the flow cannot be published until you change it.

Next to that message sits Ask us to add this table. It sends the table and the trigger to the AutoFlow team, along with your organization so we can come back to you. The button only appears while the chosen table is unsupported. Your partner can also add tables themselves with a small companion extension; ask us for the details.

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 field values​

To adjust the document before it is posted, end the flow with the Set 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).

The step's Skip standard processing option has no effect here – the document is always posted normally.

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.

Ask the user first​

Add a Confirm dialog step to put a yes/no question to the user before the posting goes ahead – for example "Credit limit exceeded. Post anyway?". End the No path with an Error step to cancel the posting, and let the Yes path carry on. Business Central's own posting question still comes first; yours follows once the user has confirmed it. Put the question ahead of any step that writes.

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.

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 Record Modified trigger instead.