One of our client requirements to show custom entity grid on
opportunity form when opportunity is closed as won otherwise hide the grid.
To achieve the requirement, I add the custom entity grid to
section on form and register a custom JavaScript function with statuscode field.
JavaScript code of
function
function showHidSubGridProjectSectionOnStatusChange ()
{
var oppStatus
= Xrm.Page. getAttribute("statuscode"). getValue();
if (oppStatus
== 3) { //3 is for Won opportunity
Xrm.Page.ui.tabs.get("Summary").
sections.get("section_subgridProjects"). setVisible(true);
} else {
Xrm.Page.ui.tabs.get("Summary").
sections.get("section_subgridProjects"). setVisible(false);
}
}
To trigger the JavaScript function, click on close As won
button and when click on Ok button the function will called.
I am showing the highlighted section when opportunity status
become won otherwise I hide it.
This method works for any entity if you want to trigger
JavaScript function on record status change.
Every entity in CRM has OOB field statuscode register
JavaScript function with statuscode field.
When record status the JavaScript code will execute.
No comments:
Post a Comment