Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to identified a sub-grid

(0) ShareShare
ReportReport
Posted on by 645

I'm working with crm 2016, I have a form with two sub-grids with views from the same Entity. When I click on the add one button of sub grid A I use certain business logic  when I use the add one  button of sub grid B I use another business logic. I need to know which sub-grid in focus or which tab in focus to distinguished between both.
How do I do that ? or if there is another option to do that ? 

*This post is locked for comments

  • Suggested answer
    sandeepc Profile Picture
    5,457 on at
  • Suggested answer
    Piotr Kerner Profile Picture
    285 on at
    RE: How to identified a sub-grid

    Ah, OK. So this is more complicated as you need to be aware that the change will impact all subgrids (also the ones on other forms!)

    Having said that, you would need to modify the "Add new {0}" button (i.e. using Ribbon Workbench, or any other tool you wish) and call custom javascript to create new form and pass information what subgrid triggered the creation (Selected Control).

    The code for opening create form is here: msdn.microsoft.com/.../jj602956.aspx

    I have described the steps needed to pass the value here: community.dynamics.com/.../276486

    Please be aware that this will include all creations of records from subgrids, regardless on parent entity, so you should also include this in your implementation

    I don't belive that the dummy flag will suffice, because you won't be able to set it up when opening new form.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: How to identified a sub-grid

    Hi ,

    Arpit answer is correct .

    For additional info please refer

    community.dynamics.com/.../sub-grid-client-side-script-methods

  • Suggested answer
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at
    RE: How to identified a sub-grid

    Hi Sahara,

    You can keep a flag or dummy field on the subgrid entity and based on the logic set it's value true or false. For Example- If you have to perform Business Logic A - Set flag value to True on subgrid form else set False.

    Then create separate views with one that only includes records having flag value set to True and one having flag value set to False. Like this way you can distinguish both the subgrids of same entity.

    Hope this helps.


    If found useful, please mark the answer as verified.


    Cheers
    Arpit
    https://arpitmscrmhunt.blogspot.com

     

  • sahara Profile Picture
    645 on at
    RE: How to identified a sub-grid

    Hey Piotr

    I have 2 subgrids with views from the same entity on one form. when I click on + and open a new from ( a record from that subgrid) I have to run a different business logic for each grid. Each sub grid in a different tab as well. I need to know when I open my NEW form where it opens from and by that term I'll run my business logic, it's not specific for a custom button. iBut if you have another option to fix my case i'll be happy to know :)

  • Suggested answer
    Piotr Kerner Profile Picture
    285 on at
    RE: How to identified a sub-grid

    hi,

    If I understand you correctly, you have custom button? If so, you need to pass the control as a CRM Parameter.

    If then you should pass the context of the control and then get it in your script. Please take a look at this article for reference:

    msdn.microsoft.com/.../gg328130.aspx

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How to identified a sub-grid

    Try this  

    var grid = Xrm.Page.getControl("subGridgridName");

    Thanks

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans