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)

Sum for subgrid and show in main form

(0) ShareShare
ReportReport
Posted on by

Hello friends, 

how to sum the values in subgrid and show in main form 

for example :

 main form name = ABC

sub grid name = 123

this is subgrid 

5277.Capture.JPG

Total Amount value should show in main form and one field

please send me the java script or plugin code.

thanks in advance

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Pitipe Profile Picture
    686 on at

    Do you specifically want code?

    This is easily done via a rollup field in the main entity, when you configure the Rollup Field, the related entity will be that of the sub grid and the aggregation will be the Sum of ( I am assuming based on screen shot) the Total Amount field.

  • Suggested answer
    Sateesh123 Profile Picture
    132 on at

    Hi Arunkumar,

    You can go for Rollup field instead of coding.

    this is for your reference :  technet.microsoft.com/.../dn832162.aspx

  • Suggested answer
    MNarmeen Profile Picture
    1,848 on at

    Make a field in main form with the name lets say "OverallAmount"

    and then add the following javascript code.

    function GetGridValues()

    {

      var rowData;

      var entity;

      var attribute;

      var i=0;

      var qty=0;

      var count=0;

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

      rowData = Xrm.Page.getControl("123").getGrid().getRows().get(0).getData();

      entity = rowData.getEntity();  

      attribute = entity.getAttributes();      

      qty= attribute.get(“new_amount”).getValue();  

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

      {

                    rowData = Xrm.Page.getControl("123").getGrid().getRows().get(i).getData();

                    entity = rowData.getEntity();  

                    attribute = entity.getAttributes();      

                    qty= attribute.get(“new_amount”).getValue();

                    count=count+qty;

      }

      Xrm.Page.getAttribute(“new_overallamount”).setValue(count);

    }

    If the above code doesnt work, use the following for currency fields

    Xrm.Page.data.entity.attributes.get(“Currency field name”).getValue();

    Xrm.Page.data.entity.attributes.get(“Currency field name”).setValue(Value);

  • Community Member Profile Picture
    on at

    i copy paste in notepad and saved .js format,

    i uploaded in websources next what i need to do.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    Use rollup field to do the same. Please go through my blog link regarding rollup fields. I explained same scenario there.

    suyati.com/how-to-set-calculated-and-roll-up-fields-in-ms-dynamics-crm

    Thanks...

  • Suggested answer
    Community Member Profile Picture
    on at

    Please use the screenshot for your reference.

    1) create a rollup field 

    2) in 'edit' option

     5811.Capture5.PNG

    Thanks..

  • Community Member Profile Picture
    on at

    i did that nly but not working

    000.JPG

  • Pitipe Profile Picture
    686 on at

    Hi Arankumar

    It take a few hours for a Rollup to automatically populate. Click into the Parent record and you will be able to refresh the field to populate the value. Is it still blank after doing that?

  • Community Member Profile Picture
    on at

    6646.error.JPG

    I am getting this error... can you please help me

  • Pitipe Profile Picture
    686 on at

    Just to confirm, the field you have created for the rollup is currency format and you have currency on the opportunity (and the field is populated)?

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