Invoke Rollup Fields Calculation programatically in CRM


Rollup field calculation is done by an async CRM Workflow , however in many scenario you may want to perform run time calculation , the following code illustrate how to invoke the calculation prgroamtically.

CalculateRollupFieldRequest rollupRequest=

new CalculateRollupFieldRequest { Target = new EntityReference("new_customentity", entityId), FieldName = "new_rollupfield"};

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