Skip to main content

Document Released

Use the Document Released trigger to run a flow interactively — in your own session, at the moment a user releases a document — for Sales and Purchase documents. Because it runs synchronously, just before the release, the flow can:

  • Prevent the release. End the flow with an Error step and the release is cancelled with your message. Ideal for enforcing extra requirements ("a contact person is required before releasing").
  • Adjust the document first. End the flow with a Set field values step and your values are written onto the header before it is released.
  • Take the release over. Turn on Skip standard processing on that step, and the document is saved with your values instead of being released – for example with status Pending Approval for your own approval process.

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 releasing a sales order until a project reference is filled in.
  • Require an external document number on purchase orders before release.
  • Default a responsible person onto the document as it is released.

What happens when the flow runs​

  1. A user releases a Sales or Purchase document from the page.
  2. AutoFlow applies your field filters. If the document does not match, the release proceeds normally.
  3. The flow runs to the end, synchronously, before the document is released:
    • If it ends with an Error step (or any step raises an error), the release is cancelled and the user sees the message; the document keeps its status.
    • If it ends with a Set field values step, those values are written onto the document and the release continues.
    • If that step has Skip standard processing turned on, the document is saved with those values and is not released by Business Central – it gets exactly the status the flow set.
    • If it just ends, the release continues unchanged.

Only the manual release (a user clicking Release) fires this trigger — releases performed automatically by other processes are left untouched.

Trigger output​

  • Rec — a reference to the document being released, so SmartFields can read its fields (e.g. {{<slug>.Rec.Amount}}) and follow-up steps can use it. It shows the status before the release – e.g. Pending Approval when an approver releases a document a flow parked there.

Configure the trigger​

Open the flow editor, pick When a document is released (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 releases the document in the client.

Timeout (seconds)​

The flow runs while the user releases the document, so keep this short.

Field Filters​

Optional. Limit the flow to documents that match certain criteria (for example Document Type = Order).

Change the document: Set field values​

To adjust the document before it is released, end the flow with the Set field values step (available in Document Released 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).

Take the release over: Skip standard processing​

Business Central always sets a released document to Released – values you set on Status are overwritten. Turn on Skip standard processing in the Set field values step when the flow should decide the outcome instead: the document is saved with your values (for example Status = Pending Approval) and Business Central's own release does not run.

Because the document is not released, the things a release normally does are skipped too: warehouse requests are not released and line amounts are not recalculated. A document that is not Released cannot be posted, so a document you parked in Pending Approval stays safe until it is released for real.

Prevent the release​

To stop the release, end the flow with an Error step and supply the message the user should see. The document keeps its status.

Ask the user first​

Add a Confirm dialog step to put a yes/no question to the user before the release goes ahead – for example "Credit limit exceeded. Release anyway?". End the No path with an Error step to cancel the release, and let the Yes path carry on. 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 release.

Build a custom approval​

The Document Released and Document Reopened triggers together let you run an approval entirely in AutoFlow, with Business Central's own statuses:

  1. Request – a Document Released flow for Sales Header. When Rec.Status is Open and the order needs approval (for example the amount is above a limit), send the approver an email and end with Set field values: Status = Pending Approval, Skip standard processing on. The order is now Pending Approval instead of Released.
  2. Approve – the approver opens the order and clicks Release again. The same flow now sees Rec.Status = Pending Approval: a Decision step checks whether the user releasing it ({{currentUser}}) is an approver. If so, let the flow end without a response step and Business Central releases the order; otherwise end with an Error step ("Only an approver can release this order.").
  3. Reject – the approver clicks Reopen instead. A Document Reopened flow sees Rec.Status = Pending Approval, informs the requester, and lets the reopen continue: the order is Open again and can be changed and resubmitted.
caution

Don't combine this with Business Central's own approval workflow for the same documents. Business Central's approval entries know nothing about the AutoFlow approval, and while they are open Business Central keeps blocking the reopen.

Record Modified vs Document Released​

These are complementary. The Record Modified trigger reacts to direct field edits and can prevent/change those. Whole-document operations like Release are best intercepted with this trigger, because it hooks the release itself and can cleanly prevent it — the modify trigger cannot reliably roll back a release.