CalculateRollupField with WebApi function in Javascript

Microsoft added with Service Pack 1 a new function called “CalculateRollupField” in Dynamics CRM (v 8.1) which enables us to recalculate a rollup field on demand.
I will show you here how you can use it in Javascript with a http request against the WebApi.

The CalculateRollupField function inside the webrequest needs a few parameter to know which rollup field you want to to calulate:

  • The EntitySetName of the target record.
    I wrote here how you can get the EntitySetName from the Metadata with an webrequest too.
  • The GUID of the target record.
  • The schema name of the target field.

CalculateRollupField in Javascript:

The answer of the webservice for the CalculateRollupField function contains the value for the target field, the date of the last calculation and its state.

CalculateRollupField Result

 

LEAVE A COMMENT