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)

CRM Online - Javascript on Form to Loop Through Grid Values?

(0) ShareShare
ReportReport
Posted on by 720

I apologize if this is an elementary question, but I'm having trouble figuring it out and a search has been somewhat fruitless.  

I have a form for my Opportunity Entity that has a grid which lists related Custom Entity (1:N hsl_solution).  What I would like to do is spin through all related rows and have a custom action based on if specific Solution is listed (hsl_product on the Solution entity).

For Example, Opportunity A may have 3 different Solutions (with Products Alpha, Beta, and Kappa) and Opportunity B has 2 Solutions (with products Beta and Omega).  Basically, I want to unhide a tab if Omega is the product listed for the related Solution.  I have code to do this if there is a field on the form that I want to check against, but going through multiple related records is just not working.

An example of Javascript code that would pull related solutions and loop through them would be very helpful or alternate thoughts would be appreciated if you have them.

Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    hellosuresh Profile Picture
    539 on at

    May be you can refer the following 

    mehmetgunen.com/crm-2013-subgrid-javascript-operations

  • Verified answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi!

    I just saw the perfect solution for what you're trying to do. CRM 2016 introduced a lot of new ways to work with subgrids on a form. They've added javascript methods to let you get the grid, the grid rows, the selected grid rows, the entity behind the row, etc. It's really exciting; all the specs are here: msdn.microsoft.com/.../dn932126

    Hope this helps! I'd appreciate if you'd mark this as a Verified answer.

    Thanks,

     Aiden

  • BJMcmullan Profile Picture
    720 on at

    @hellosuresh that seems to be exactly what I was looking for.  Thanks for pointing it out!

    @ Aiden Kaskela, your answer is quite helpful, but we're still on the 2015 Update 1 Version (the 2016 update hasn't been offered to our tenant group yet).

     

    Thank you both!

    For anyone searching, the javascript is:

    var gridControl = document.getElementById('subgrid_id').control;

    var ids = gridControl.get_allRecordIds();
    for (i = 0; i < ids.length; i++) {
        var cellValue = gridControl.getCellValue('column_name', ids[i]);
        // DO WHATEVER YOU WANT WITH THE CELL VALUE HERE!..
    }
    From http://mehmetgunen.com/crm-2013-subgrid-javascript-operations/ (thanks hellosuresh), the site also has a number of other helpful examples.

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