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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Rollup field calculation not working

(0) ShareShare
ReportReport
Posted on by 7,316

Hi,

I am trying to use a rollup field for the first time. I have a Case entity and it's child entity 'Expenses'. Each expense record has a currency field which in turn is a calculated field. This field calculates total amount of the expense record.

So, I need my rollup field to calculate the total of each expense record(Calculated field). I know that rollup fields can't reference a calculated field and So I've created a hidden currency field on expense record and added a script to copy the calculated value. And then, used that hidden field for calculating rollup value on Case form.

But nothing happens on the case form when I created a couple of expense records. The rollup field(on case Form) always remains blank, I did press refresh button.  The calculation itself is fairly simple. Just the sum of all the expense amounts. What could be the reason.. please guide me through this.

Thanks for any help.

*This post is locked for comments

I have the same question (0)
  • Wayne Walton Profile Picture
    13,728 on at
    RE: Rollup field calculation not working

    Did you make sure your script is actually storing that other value?  Make sure there's something there for the rollup to use.

    And technically a rollup can reference a calculated field, just not a calculated field that references another calculated field: technet.microsoft.com/.../dn832162.aspx

  • meenoo Profile Picture
    7,316 on at
    RE: Rollup field calculation not working

    Yes, the script is working fine. It fills in the value.. I'm sure about it.

    And I am sorry, I wasn't clear earlier. Yes, my calculated field on child entity uses another calculated field in the aggregation. So I can't use it for rollup calculations.

    As per this statement from the msdn article you pointed out.

    •A rollup can't reference a calculated field that uses another calculated field, even if all the fields of the other calculated field are on the current entity

    I found that in the database, the rollup field value is 'NULL' but 'fieldname_base' has the actual calculation. Also, 'fieldname_State' shows 1.

    Not sure what else to try. Any other suggestions would be great.

    Thank you.

  • Verified answer
    Neil Parkhurst Profile Picture
    10,727 User Group Leader on at
    RE: Rollup field calculation not working

    This post describes rolled up fields, it might help.

    neilparkhurst.com/.../mb2-712-certification-microsoft-dynamics-crm-2016-customization-and-configuration-rollup-fields

    I have certainly done something similar to you before. Rather than a script I used a business rule to copy the calculated value to an actual value field. Which was then rolled up.

    My business rule had a scope of entity, a condition of if "calculated value" does not equal "actual value", in the action I had "set actual value to calculated value - 0"

    the most logical explanation to your problem would be that the actual value hadn't been set by the script at the point you are refreshing the rolled up field. But I guess you have looked at that already. It could be there is something wrong with your script, maybe try a business rule instead.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Rollup field calculation not working

    Roll-ups are finicky. They are set to refresh every 24 hours; they don't automatically re-calculate on save or refresh of the page. Did you refresh the page or the roll-up field itself?

    First, make your hidden fields visible to ensure they're populating correctly. Then save the case. Then click on the calculator next to the roll-up field and the refresh button on the field (to the far right of the roll-up field).

    This may be obvious to you but you said this is your first try with roll-ups.

  • meenoo Profile Picture
    7,316 on at
    RE: Rollup field calculation not working

    Thanks Neil. I did try creating a business rule to fill in the total in a hidden field. But it did not work as the 'Calculated total' field does not show up when I try to set it to the hidden field. I've tried to create business rule with scope as entity and the calculated field won't show up.

    So I had to write a script to fill in the hidden field.

    I've even tried setting up the rollup field to sum 'another' field(simple currency data type) of child entity and that won't work either. I am totally frustrated and not sure what else to try.

    Thanks.

  • meenoo Profile Picture
    7,316 on at
    RE: Rollup field calculation not working

    Thanks Melissa. I tried all your suggestions but still not working!

  • Verified answer
    meenoo Profile Picture
    7,316 on at
    RE: Rollup field calculation not working

    Ok, for some reason I thought of closing all the browsers and starting fresh did the trick!

    The rollup field is now working.

    Neil - I did build a business rule to set the hidden field which defaults to calculated amount on child entity instead of a script.

    But, the only small issue is, whenever I save the child entity for the first time.. I am seeing 'Unsaved Changes' in the bottom. And until I hit 'save' again, the rollup value won't update even if I click 'refresh' button. Any workaround surrounding this small issue??

    Thanks.

  • Neil Parkhurst Profile Picture
    10,727 User Group Leader on at
    RE: Rollup field calculation not working

    Hmmmmm .... I guess the reason is the business rule is updating the actual field when you click save. Causing an unsaved change. (You may have had the same thing effectively happening with your script. Although as the browser refresh solved the problem you script could have always been working!)

    I think I have seen something similar before but in my case I was updating the rolled up fields using a real time workflow. (You can get some workflow tools to do this on codeplex. https://msdyncrmworkflowtools.codeplex.com/)

    I wonder if you could avoid this issue by setting the actual value using a workflow and also if needed force the roll up.

    I think Melisa described rolled up fields as finicky. She is right as getting the timing bang on for the updates can be "finicky".  (Especially as you have calculated fields involved.)

  • meenoo Profile Picture
    7,316 on at
    RE: Rollup field calculation not working

    Yes, the unsaved changes error comes up for both business rule and script. I am trying to find a workaround for this.

    One other strange issue I'm facing is, not sure if you have any answer for it.. but

    The rollup field works only for new records and won't work for the existing records. I mean, for example, I have lots of cases already in the system where this rollup field was created on. It won't calculate for the existing cases and it's child records.

    Works only if I create a new case and add child records with amount entered in them.

    What do you think the reason could be? Please let me know your thoughts.. it will be big help for me to work through this.

    Thanks.

  • meenoo Profile Picture
    7,316 on at
    RE: Rollup field calculation not working

    I figured the problem was with the transactioncurrencyid being 'null' for all the existing records that were created before rollup field. That's why all the new records with rollup field work properly.

    I am not sure how to workaround through this issue. So opening new question about it.

    As far as this thread, I was able to pass through this issue.

    Thanks.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans