Hello,
Our organization uses Dynamics CRM 2015 on premise. I am attempting to create a javascript function within the Order entity to hide/show a custom entity subgrid based on a checkbox selection. I want this to occur on load at the moment, I may also implement it on change of that field if I can get it working this way first. Below is the script I have so far.
function hardwareIncluded(){
var HardwareStatus = Xrm.Page.getAttribute("new_hardwareincluded").getValue();
if(HardwareStatus == false)
{
Xrm.Page.ui.controls.get("HardwareShipments").setVisible(false);
}
else
{
Xrm.Page.ui.controls.get("HardwareShipments").setVisible(true);
}
}
In this script, "new_hardwareincluded" is the name of the two option field that is configured as a checkbox at the moment. "HardwareShipments" is the name of the subgrid within the Order form where this Javascript is being called on as an onload function. Below is an image of the error I am currently getting when I open an Order record, I tried with one that was checked and one that was not checked, same result. Any thoughts on this? Thanks!
*This post is locked for comments
You are welcome. Glad it worked out. :)
meenoo,
I really couldn't find anything wrong with the subgrid name I selected, if I open the details on that subgrid that's exactly what's listed under the name.
That being said, using your code to hide/show an entire section worked perfectly. I think I'll just reorganize a bit and go that route instead of looking further into calling the subgrid. Thank you so much for your response, you saved me a bunch of time!
Hi CRMUser13,
Have you checked the subgrid name? Is it correct?
Try to place subgrid in a section and make the section hide/show instead of subgrid.
Like this:
Xrm.Page.ui.tabs.get(TabName).sections.get(SectionName).setVisible(true);
Thank you.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156