Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

read subgrid column value

Posted on by Microsoft Employee

i wrote these codes to count distinct items from a subgrid based on value of a column :

function GetGridValues()

{

  var rowData;

  var entity;

  var attribute;

  var i =0;
 
  var columnValue;
 
  var counts =1;

  var filteredRecordCount =  Xrm.Page.getControl("invoicedetailsGrid").getGrid().getTotalRecordCount();
 

  for( i=0; i<filteredRecordCount ; i++)

  {

                rowData [i] = Xrm.Page.getControl("invoicedetailsGrid").getGrid().getRows().get(i).getData();

                entity = rowData.getEntity();  

                attribute = entity.getAttributes();      

                columnValue [i]= attribute.get('new_main_team').getValue();

  }
 
  columnValue.sort();
  for (j = 0; j < columnValue.length ; j++) {
           if (columnValue[j] != columnValue[j+1]) {
               counts += 1;
           }
  }        
 Xrm.Page.getAttribute("new_mainteam_count").setValue(counts);

}

but it does not work  and display these  error :

object does not support property or method "getGrid"

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: read subgrid column value

    this column is related to a related entity!

    invoice(subgrid) ->invoice product ->salesperson(main team field)

  • Darshik Profile Picture
    Darshik 295 on at
  • Verified answer
    Darshik Profile Picture
    Darshik 295 on at
    RE: read subgrid column value

    Hi,

    Retrieve the record from the related entity directly, use the retrieve multiple on the  related entity.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans