In model-driven application, I want to close side panes when a user leaves a form.
Where to put the script for side panes closing? Or how to call it when leaving the form? I was not able to find any handler for “OnExit” / “OnClose” / “OnUnload” on the form. Not even any handler on the grid / view to call the script to close side panes.
I already tried adding the script to “OnSave” handle in the form, which works only in case the user press “Save & Close” button. However, my users usually do not need to click that button and directly somewhere else.
The story:
-
User goes to a model-driven application and opens a grid with records for a table “ideas”.
-
The user opens a record from the grid and the form loads.
-
When a for loads, side pane opens. In the side pane is custom page to show relevant information for that opened record using parameter in custom page.
-
When a user clicks the “Back” button or even selects another table from the left menu, the side pane still stays open. With the details for a record which is already closed.
I have this script to close all side panes:
function closeAllPanes() {
var allPanes = Xrm.App.sidePanes.getAllPanes();
allPanes.forEach(function(pane) {
pane.close().catch(function(error) {
console.error("Error closing pane: ", error);
});
});
console.log("Side panes closed.")
}
petrhellmich is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.