Hi @manishsg ,
Thank you for the post.
Regarding the calculation of rollup fields, there are different methods of doing this, however there is a limitation behind it, you can not trigger the calculation of rollups based on the rollup calculation.
You can trigger a flow at a certain time and from there you can send an Web API request as a Http request, here's an example of a script being able to perform this action, please remove the line numbers and adapt it to the requirements you have in the Power Automate infrastructure, keeping in mind the number of records retrieved during this operation needs to be below a certain limit, otherwise the Power Automate won't be able to update them:
1. var Sdk = window.Sdk || {};
2.
3. Sdk.CalculateRollupFieldRequest = function (target, fieldName) {
4. this.Target = target;
5. this.FieldName = fieldName;
6. };
7.
8. Sdk.CalculateRollupFieldRequest.prototype.getMetadata = function () {
9. return {
10. boundParameter: null,
11. parameterTypes: {
12. "Target": {
13. "typeName": "mscrm.crmbaseentity",
14. "structuralProperty": 5
15. },
16. "FieldName": {
17. "typeName": "Edm.String",
18. "structuralProperty": 1
19. }
20. },
21. operationType: 1,
22. operationName: "CalculateRollupField"
23. };
24. };
25.
26. function myTestFunction() {
27.
28. //create variables to point to a quote record and to a specific field
29. var quoteId = {
30. "@odata.type": "Microsoft.Dynamics.CRM.quote",
31. "quoteid": "GUID" // add in here your record ID or parametrize this in order for it to be retrieved
32. };
33. var fieldName = "field_name"; // add in here your field schema name
34.
35. //create variable calculateRollupFieldRequest and pass those variables created above
36. var calculateRollupFieldRequest = new Sdk.CalculateRollupFieldRequest(quoteId, fieldName);
37.
38. // Use the request object to execute the function
39. Xrm.WebApi.online.execute(calculateRollupFieldRequest).then(
40. function (result) {
41. if (result.ok) {
42. result.json().then(
43. function (response) {
44. console.log("The response is: %s", response);
45. });
46. }
47. },
48. function (error) {
49. console.log(error.message);
50. // handle error conditions
51. });
52. }
Also you can have that request being sent by an external endpoint using Web API but first you need to make sure you had logged in successfully.
You can even trigger this as a plugin on update for that particular entity post-operation, but you need to make sure your request will not be throttled due to too many requests in a short period of time, regardless of the method you want to use.
The documentation of the CalculateRollupFieldRequest is available here:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.crm.sdk.messages.calculaterollupfieldrequest?view=dynamics-general-ce-9
Thank you for using Microsoft Communities,
Madalina Toma
Support Engineer
Microsoft Dynamics 365