Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Using Javascript to get the name or label of a sub grid?

(0) ShareShare
ReportReport
Posted on by 1,589

I have an entity named Franchise Config and on one of its Forms named Franchise Defaults (shown below) I have many Subgrids (sub grids names are circled in purple below) that point to various views on a different entity named Franchise Defaults.

Screen-Shot-2021_2D00_05_2D00_12-at-5.24.40-PM.png

An example of one of the subgrids showing the name and label along with the selected view can be seen below.

Screen-Shot-2021_2D00_05_2D00_12-at-5.30.37-PM.png

I have customized the + new franchise default button (circled in turquoise above) via ribbon workbench so that it executes a custom script. 

I need to make the custom script get either the name or label of the subgrid properties area the + new franchise default button is clicked from.

 I need to pass the name or label of the subgrid to another function that opens a new create form and pre-populates a bunch of different values based on the name or label that is passed.  

How can I get the name or label of the subgrid properties area the + new franchise default button is clicked from via JavaScript that runs when the button is clicked?

Any help would be greatly appreciated. 

  • vishal bagadia_crm Profile Picture
    490 on at
    RE: Using Javascript to get the name or label of a sub grid?

    Perfect.. That is exactly I was trying to convey.

    will try to be more precise and clear about the answers I send from next time so that person can understand very clearly without any issues..

    Thank you for your replies and feedback.

    Regards,

    CRM Developer

  • vishal bagadia_crm Profile Picture
    490 on at
    RE: Using Javascript to get the name or label of a sub grid?

    Hello Jim,

    The screenshot I shared shows custom button of my project. Its just for the reference. You will see the parameter options for any OOB/custom entity in any project.

  • ACECORP Profile Picture
    1,589 on at
    RE: Using Javascript to get the name or label of a sub grid?

    Awesome. I customized the button and changed the command so that it executes my script (shown below) and function instead of the OOB.

    function GetFranchiseDefaultType(primaryControl, SelectedControl) {
        debugger;
        "use strict";
        alert("Selected Control Name is: "   SelectedControl.name);
        }

    The button and command customizations are shown below and this works! 

    Screen-Shot-2021_2D00_05_2D00_13-at-3.40.00-PM.png

  • ACECORP Profile Picture
    1,589 on at
    RE: Using Javascript to get the name or label of a sub grid?

    Your example shows a sales order line items button, but I would be using the +new button.

    Does that matter? I see in ribbon workbench that same parameter is present on the new button.

    Do I need to change the script that is run when the new button is pressed or can I simply adds function to on load of the form that opens up when the new button is pressed and check the SelectedControl.name to get the name?

    Any additional specificity you can provide would be very helpful.

  • Verified answer
    vishal bagadia_crm Profile Picture
    490 on at
    RE: Using Javascript to get the name or label of a sub grid?

    Hello Jim,

    In the ribbon workbench you can pass CRM Parameter as "SelectedControl" to your function, which can give you more details in your javascript

    pastedimage1620889834973v1.png

    Regards,

    CRM Developer

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Product updates

Dynamics 365 release plans