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 sum up a bunch of currency fields on an entity....

(0) ShareShare
ReportReport
Posted on by 26

I am wondering how I can go about summing up a bunch of currency fields on an entity and then take that sum and put the total in another currency field.  Example:

If fiedl1, field2, field3, field4, field5 all have a value in their field, then sum those up and place the total in field x.  But, if one of them does not have a value in, then the field x should be an open currency field where the user can enter in a value if need be.

Thank you in advance for your help.

*This post is locked for comments

I have the same question (0)
  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Not sure I completely follow, but why don't you create a calculated field for the total...

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    You can try creating a calculated currency field for summing up all these fields.

    See: technet.microsoft.com/.../dn832103.aspx

    But it has a limitation that we cannot manually edit a calculated field. It is a read-only field.

    Another alternative is to create a simple currency field and write a business rule with scope as Entity to set its value to the sum of all other currency fields required.

    See: technet.microsoft.com/.../mt826761.aspx

    Hope this helps.

  • USA80 Profile Picture
    26 on at

    How would you do the sum of the fields though?  I don't see a Sum function in the business rule to select.

    Also, could it work by having 2 fields, 1 would show if all fields are filled in and then it would sum those fields and put the sum amount in Field X.  If anyone of those fields are not filled in, then Field Y would appear and Field X would hide?

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Hi,

    You can create conditions in calculated field so that you have various criteria.

    There is no SUM function, but you can set the value to SUM multiple fields:

    = new_Field1 + new_Field2 + new_Field3...

    Hope this helps.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    There is no SUM function but you have the Formula function and you can add more than one field as described in the link below.

    See: https://community.dynamics.com/crm/b/exploringdynamics365/archive/2017/10/19/dynamics-tip-using-business-rules-to-sum-up-more-than-two-fields

    You could also hide the fields accordingly based on the condition in the business rule.

    Hope this helps.

  • che Profile Picture
    67 on at

    Hi,

    you can use business rule to calculate fields ,but the logic will be too long .

    I suppose to put those fields in the same section, and add a javascript to calculate them.

    regards

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    if you want to be able to sum up and lock/unlock the field depending on the conditions. The better way to achieve it is with the help of a javascript function.

  • Suggested answer
    Ryan Maclean Profile Picture
    3,070 on at

    You could try and use a calculated field, but this won't be manually editable.

    You could also import the Numeric Workflow Utilities written by Jason Lattimer (github.com/.../CRM-Numeric-Workflow-Utilities) and use this to create a workflow to sum up the fields

  • USA80 Profile Picture
    26 on at

    I have tried the following and I keep getting an error that says, "Object doesn't support property or method 'setValue' at onChangeFeeType

    function onChangeFeeType()

    {

    var RecordType = Xrm.Page.getAttribute("nhs_recordtype").getText();

    var Car1 = Xrm.Page.getAttribute("nhs_car1").getValue();

    var Car2 = Xrm.Page.getAttribute("new_car2").getText();

    var Car3 = Xrm.Page.getAttribute("nhs_car3").getValue();

    var Car4 = Xrm.Page.getAttribute("nhs_car4").getText();

    var Car5 = Xrm.Page.getAttribute("nhs_car5").getValue();

    var Car6 = Xrm.Page.getAttribute("nhs_car6").getText();

    var Car7 = Xrm.Page.getAttribute("nhs_car7").getValue();

    var Total = parseFloat(Car3) + parseFloat(Car5);

    if (RecordType == null || RecordType =='undefined' || RecordType =='')

    {

    Xrm.Page.getAttribute("nhs_car1").setValue("");

    }

    else if (RecordType == "GTO" && Car2== Car4)

    {

    Xrm.Page.getAttribute(Car1).setValue(Total);

    }

    }

    Any help is appreciated.  Thank you.

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Hi USA,

    Please look at your attributes.

    Why are some of them are getValue and some are getText.

    They should all be getValue???

    Also, regarding your error:

    Xrm.Page.getAttribute(Car1).setValue(Total);

    getAttribute should have a field name inside, not a variable name.

    Car1 contains a non-string value.

    Hope this helps.

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