web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

JavaScript to show/hide sub-grid based on checkbox selection onload?

(0) ShareShare
ReportReport
Posted on by

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!

Order-Javascript-Error.PNG

*This post is locked for comments

I have the same question (0)
  • Verified answer
    meenoo Profile Picture
    7,316 on at

    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.

  • Community Member Profile Picture
    on at

    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!

  • meenoo Profile Picture
    7,316 on at

    You are welcome. Glad it worked out. :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans