​Show Hide Control on Form in JavaScript on Record Status Changed Dynamic 365

Introduction

One of our client’s requirements was to show a custom entity grid on the opportunity form when the opportunity is closed as won. The client wanted the grid to be hidden otherwise. To achieve the required, I added the custom entity grid to the section on the form and registered a custom JavaScript function with the status reason field to hide control on form in JavaScript.

Learn more about our Microsoft Dynamics 365 services!

JavaScript code of function

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 the “Close As Won” button and then click the OK button; the function will be called.

I show the highlighted section when the opportunity status is won; otherwise, I will hide it.

Read more: Develop PCF Control: Show Activities in Sub-Grid

That’s it for today. I hope it helps you. If you have any questions or queries, please contact us!  

Streamline your CRM Interface with JavaScript!

Ready to explore how "Show Hide Control on Form in JavaScript" can transform your Dynamics 365? With AlphaBOLD, unlock advanced customization and seamless data management. Embark on your journey to a smarter CRM.

Request a Demo

Explore Recent Blog Posts

Infographics show the 2021 MSUS Partner Award winner

Related Posts

Receive Updates on Youtube