As D365FO Reporting and Print management experts, we’ve frequently been asked - where is, for goodness’ sake, the Close button (which became the Back button in the meantime 😀) on the Print management setup form. We also saw the feature request on Dynamics 365 Application Ideas, so we decided: it’s time to take some action 😎.
How to add the Back/Close button
This is a very simply solution – extend the PrintMgmtSetupUIMain form and add an Action Pane. The Back button (ex the Close button) will appear automatically. There is additional work though: we need to hide all other non-applicable System buttons such as New, Delete, Options, Attachments, etc. which will also appear automatically, like the Back button.
Check the code how to hide all other buttons or download the resources:
// New button
FormCommandButtonControl newButton = this.control(this.controlId(#SystemDefinedNewButton)) as FormCommandButtonControl;
// Delete button
FormCommandButtonControl deleteButton = this.control(this.controlId(#SystemDefinedDeleteButton)) as FormCommandButtonControl;
// Options tab
FormActionPaneTabControl optionsActionPaneTab = this.control(this.controlId(#SystemDefinedOptionsActionPaneTab)) as FormActionPaneTabControl;
// PowerApps button
FormMenuButtonControl powerAppsButton = this.control(this.controlId(#SystemDefinedPowerAppsMenuButton)) as FormMenuButtonControl;
// Attach button
FormCommandButtonControl attachButton = this.control(this.controlId(#SystemDefinedAttachButton)) as FormCommandButtonControl;
// Office button
FormMenuButtonControl officeButton = this.control(this.controlId(#SystemDefinedOfficeButton)) as FormMenuButtonControl;
// Refresh button
FormCommandButtonControl refreshButton = this.control(this.controlId(identifierStr(SystemDefinedRefreshButton))) as FormCommandButtonControl;
How to add the Save button
Adding the Save button is a bit more complicated than adding the Back button. The Save button gets already visible when we add the Action Pane. However, we also need:
(1) To make the form always editable in order to prevent switching between the Save and Edit buttons.
This can be done in the following way:
(2) To create a method that actually saves the changes made in the setup.
Essentially, we need to use the existing saving mechanism as it is done in the base form PrintMgmtSetupUIMain:
public void SystemDefinedSaveButton_OnSaving_DC()
// Save all changes on the form
Where ctrl is an instance of the controller class PrintMgmtSetupUICtrl, used for building up the Print management setup form and handling all the actions such as adding new Print management settings, configuring and deleting them.
In order to invoke the above method, we subscribed to the Saving delegate, exposed via FormRun.dataHelper(), an instance of the FormRunDataHelper class.
// Subscribe to the Saving delegate. The delegate is called when the standard Save button is clicked.
// Since the event handler method cannot be created in the form extension class because it's not
// to compiler, the event handler method is created in the PrintMgmtSetupUIMainForm_DC_EventHandler class,
// from which the method SystemDefinedSaveButton_OnSaving_DC is called in this form extension,
// when the standard Save button is clicked.
PrintMgmtSetupUIMainForm_DC_EventHandler printMgmtSetupUIMainFormEventHandler =
Alternatively, we could use the registerOverrideMethod() method for the Save button since we can read its Control ID from the SysSystemDefinedButtons macro – as we did for other System buttons in order to hide them.
There is more
To the Print management setup form we also added:
- The Open in new window button,
- Current company, e.g. Print management setup (USMF),
- Link to an article explaining Print management setup,
- Link to Print management utilities, which offers a tabular view of all Print management settings in the system including overrides, advanced filtering, search and validation, bulk update and delete.
Additionally, we placed all Print management setups for all modules in the Docentric AX workspace (check the article) and enable tracing of loading and resolving Print management settings (check the article).
We also created Print management preview on common journals (check the article) and Print Management Data Entity for moving Print management settings between companies and environments (check the article).
We blogged a lot on Print management too 😀
The following articles explain Print management setup in great detail: