Skip to main content

Page Closed

Use the Page Closed trigger to run a flow interactively – in your own session, at the moment a user closes one of the supported card pages, and before the page actually closes. That order is the point: the flow can keep the page open.

Typical examples:

  • Keep a sales order open until a project reference is filled in.
  • Remind the user of a follow-up they were supposed to complete on this record, and let them decide.
  • Stop someone leaving a customer card with an incomplete address.

Supported pages​

The same 16 card pages as Page Opened – the six sales documents, the six purchase documents, and the customer, vendor, contact and item cards. Picking an unsupported page is caught the same way: the status line says so while you configure, the flow cannot be published, and Request support sends the page to us.

What happens when the flow runs​

  1. A user closes one of the supported pages.
  2. AutoFlow applies your field filters. If the record does not match, the page closes normally and no flow runs.
  3. The flow runs to the end, synchronously, before the page closes:
    • If it ends with a Prevent page close step, the page stays open and your message is shown.
    • If it ends with an Error step (or any step raises an error), the page also stays open – but the user sees an error dialog rather than a friendly message. Prefer the Prevent step.
    • If it just ends, the page closes as usual.

As with Page Opened, a new record that was never saved and a record that no longer exists never start a flow. The second one matters here: after someone deletes a record, Business Central closes the card automatically and the record is gone, so no flow runs and nothing can block that close.

The trigger fires on every close, including when the user presses Escape or the back arrow – the flow cannot tell those apart.

Trigger output​

  • Rec – a reference to the record the page was showing.
  • PageNo – the number of the page being closed.

Configure the trigger​

Same fields as Page Opened: the page, the derived record, a timeout, and optional field filters. Keep the timeout short – the user is waiting to leave.

A notification in the page's bar is of little use here. The user is on their way out of that page, so nobody would read it. Say what you have to say through the Prevent page close step, which keeps the page – and the reader – in place, or use Send Notification with Show as set to Dialog message.

Prevent the close​

Add the Prevent page close step at the end of the path that should keep the page open, and give it a message explaining what to do. See Prevent page close.

Put it behind a Decision so it only triggers in the case you care about – a flow that prevents unconditionally makes the page unclosable for everyone who opens it. Unpublishing the flow releases it again immediately.