cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ricfernandes
Regular Visitor

Force rollup fields calculation

Dear community,

I'm creating a POC for a client for them to decide whether to go for the Power Platform for replacing a legacy application. The strategy is to use the model-driven approach as far as possible, thus the end result will be a set of business entities which will be manipulated by one or more model-driven apps.

The biggest blocker point so far is that I need several rollup fields to be calculated as soon the data is entered in the entities they refer to. I know we can go to each rollup field and force the value to be updated in the model-driven app directly by hitting the "Update" button that appears next to the field. The thing is that the client wants to have a single button to update all rollup field at once.

Is there a way of doing that? Thanks in advance!

13 REPLIES 13
tschopp
Advocate III
Advocate III

The author of "Dynamics 365 Workflow Tools" has released an entity neutral version called "Power Platform Workflow Tools".  It's a new project that excludes classes with dependencies on Microsoft Sales and Customer Service.  It deploys into a stock Power Platform environment.

 

https://github.com/james-tekstack/Dynamics-365-Workflow-Tools/releases/tag/1.0.61.1

BradleyF1
New Member

For those that find this post in the future.

Here is a great Blog post, discussing how to force the Calculate Rollup using a Power Automate.
Calculate Rollup Fields by Power Automate (boruwang.com)

jamesreinhardt
Frequent Visitor

You should be able to execute an oData request against the web api to force the recalculation of individual rollup fields. Example code is here:

https://docs.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-weba...

Dlabar
MVP

If you are looking to do this as a one-off, you can run this code in the Code Now tool for the XrmToolBox:

public static void CodeNow(){
    var request = new Microsoft.Crm.Sdk.Messages.CalculateRollupFieldRequest{
        FieldName = "new_fieldlogicalname",
        Target = new EntityReference("new_entitylogicalname", new Guid("12345678-d18f-ec11-b400-002248248cc6"))
    };
    
    Service.Execute(request);
    LogMessage("Done");
}

 Just update the FieldName and Target appropriately.

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,161)