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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans