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)

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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Try this  

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

    Thanks

  • Suggested answer
    Piotr Kerner Profile Picture
    285 on at

    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

  • sahara Profile Picture
    645 on at

    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
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at

    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

     

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Arpit answer is correct .

    For additional info please refer

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

  • Suggested answer
    Piotr Kerner Profile Picture
    285 on at

    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
    sandeepc Profile Picture
    5,514 on at

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