Sometimes in Dynamics 365 Finance & Operations (D365F&O) you need to refresh a form programmatically — for example, after executing some logic that updates records shown on the screen.
While formRun().dataSource().reread()
or research()
can work in many cases, they don’t always replicate the same behavior as clicking the built-in Refresh button. The most reliable way to trigger a full refresh identical to the user action is to programmatically invoke the click event of the standard refresh button itself.
FormCommandButtonControl refreshButton = sender.formRun().control(sender.formRun().controlId('SystemDefinedRefreshButton'));
refreshButton.clicked();
How It Works
sender.formRun()
gives you access to the current form runtime object.controlId('SystemDefinedRefreshButton')
retrieves the control ID for the form’s system-defined Refresh button.The control is cast to a
FormCommandButtonControl
, and theclicked()
method is invoked to simulate a user click.
This approach ensures the form behaves exactly as if the user manually pressed Refresh — re-reading data sources, re-initializing controls, and executing any form refresh logic configured by Microsoft or customizations.
When to Use It
Use this method when:
You’ve performed backend logic that updates data displayed on the current form.
You need to ensure all controls and data sources are fully refreshed (not just re-read).
You want to maintain standard refresh behavior consistent with the D365F&O UI.
Caution
Make sure you call this from a safe context (e.g., within a button click handler, process guide step, or post-update event) to avoid recursion or refresh loops.
Avoid calling it repeatedly in a single transaction — it triggers a full UI refresh each time.