Programmatically Recalculating Rollup fields using C# in Dynamics 365/CRM

Hi Everyone,

Today I got an requirement to send some data to external system and they were looking for real time data. When I did the fields found some Rollup fields and we all know that Rollup fields are asynchronous in nature and it is managed by Recurring System Jobs.

I was kind of stuck, did a little search and understood that there is a SDK message which we can use for recalculating. Here is the code for the same.

CalculateRollupFieldRequest rollupRequest = new CalculateRollupFieldRequest
            {
                Target = new EntityReference("account", new Guid("475b158c-541c-e511-80d3-3863bb347ba8")),
                FieldName = "new_rollupfromchild"
            };

            CalculateRollupFieldResponse response = (CalculateRollupFieldResponse)crmService.Execute(rollupRequest);

Hope this helps.


Happy 365’ing
Gopinath.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s