Automatically calculate Rollup fields in Dynamics 365 – A utility from XrmForYou consulting

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com
Frustrated about customers complaining that Roll-up fields are not calculating at runtime? Abandoned rollup fields and went for something custom because customer couldn’t afford the calculation to happen every hour? The good news is that you do not need to worry about all these any longer. The new Automatic Rollup Calculator solution from XrmForYou tackles all these scenario and does much more.
Dynamics 365 offers a wonderful UI based editor to define your roll-up fields. It’s quite powerful. However whenever we go to customer and say that roll-up fields are not calculated at run-time, it puts us in some shaky situation. Our tool does the following:

  • Identifies any changes in the child entities involved in the roll-up field definition and automatically calculates the roll-up field values
  • Handles scenario when
    1. Child record is created
    2. Child record is deleted
    3. Child record is updated. Handles both the scenarios when associated parent of the child record is changed or the field of the child entity involved in the calculation of roll-up field is updated.
    4. On-demand calculation of all roll-up fields of a record.

And all of these with just few configuration steps. So let’s see how our tool works.
For trial and pricing, please write to us at info@xrmforyou.com. Video and documentation coming soon on www.Xrmforyou.com website.
The tool comes in the form of managed solution. Once you install, it will appear in your solutions area.
Solution Name – XrmForYou.RollupfieldCalculator.
image
Open up the solution and navigate to the configuration Page. You will see a screen like the one shown below.
image
For this documentation, I have set up the following structure.

  • Created an Entity – Test Entity
  • Set-up 1:N relationship with Contact
  • Created two roll-up fields
    • Count of Contacts – Rollup field showing the number of contacts associated with the Test Entity
    • Contact Credit Limit Sum – Rollup field showing the aggregate of the credit limit field of the contacts associated with the Test Entity.

Definition of both the fields in screenshots below.
image                  image
Okay. So far so good.
I select my Test Entity from the DropDown and all the roll-up fields of the entity shows up.
image
This UI helps me pick and choose which roll-up field I want to enable for automatic calculation
I select both and click on Save Configurations button. The system will start setting the roll-up field configuration for the selected fields. You can monitor the state of the operation by going to Settings –> System Jobs


JobName – x4uru_ActionRegisterSDKStep.
image
image
If the job fails, you need to open and see the error. If the job succeeds, it will disappear from the system jobs list.
Once successful, you are all set.
For testing I create two records – “Test Record 1” & “Test Record 2”.
For both the records the roll-up fields are showing 0 which is expected.
image
I open up Test Record 1 and associated 4 contacts.
image
If I now refresh, my advanced find view, I can immediately see the roll-up fields being updated.
image
Please note that in order to avoid any performance issues, the roll-up field calculation happens through asynchronously the moment any changes are made to the child entity. Hence if your async job is stuck sometimes you may experience a bit of delay. But usually all this will happen within seconds of updating the child entity.
Now I open up any contact associated with Test record 1 and associate it with Test Record 2.
Immediately when I come back and refresh my advanced find view, I can see the results.
image
Cool. Now before I wind up, there is one more feature that the tool comes with. Once you install the solution and open up any entity form, you will see a new button in the Menu called – “Calculate Roll-up Fields”.
image
Say you don’t want to go for automatic calculation but you want the user to have an option of updating all the rollup fields on a record on-demand. You have this option which allows you to do exactly like that.
Click on the button and the dialog pops-up where you can pick and choose the roll-up fields to be updated.


image
Select the desired fields and then click on Update. The page will refresh to show the latest roll-up data.
If you believe this tool works for your organization, you can request for trial and pricing at info@xrmforyou.com.
Video and documentation will be uploaded in our website www.xrmforyou.com soon.
Debajit Dutta
(Dynamics MVP)