web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Call the OOB script to refresh a rollup field

(0) ShareShare
ReportReport
Posted on by 365

i want to refresh a rollup field in my form but i don't know when i click on the small refresh button on the right of the rollup field which script is triggered is there anyway i can call the the function on my custom javascript so i can refresh the rollup field instead of using a plugin which recalculating in the server but not updating the form so i have manually do it

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hello,

    You can do using custom workflow activity and then using JavaScript html webresource create button  to refresh rollup fields-  

    Please check here -

    community.dynamics.com/.../calculate-rollup-fields-on-button-click

  • Anas Rafik Profile Picture
    365 on at

    yes i already created a synchronous plugin recalculating my field then i reloaded the entire form but i don't want to perform all of this i am searching form the oob script so i can trigger it from my javascript

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    I don't think there is any OOB  script available to refresh the rollup fields.

  • Verified answer
    Yusi Profile Picture
    100 on at

    Yes , the code below works perfect for me.


    function CalculateRollupField(EntityName, recGuid, RollUpFieldName)

    {
    recGuid = recGuid.replace("{", "").replace("}", ""); // String Guid

    var HttpReq = new XMLHttpRequest();

    HttpReq.open(this.method, this.url, true); // Need this to initiate the request

    HttpReq.setRequestHeader("OData-Version", "4.0");

    HttpReq.setRequestHeader("OData-MaxVersion", "4.0");

    // Double Check your API URL, may differ for v9.0
    HttpReq.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/" + "CalculateRollupField(Target=@p1,FieldName=@p2)?" + "@p1={'@odata.id':'" + EntityName + "(" + recGuid + ")'}&" + "@p2='" + RollUpFieldName + "'", true);

    HttpReq.onreadystatechange = function ()

    {

    if (this.readyState === 4)

    {

    HttpReq.onreadystatechange = null;

    if (this.status === 200)

    {

    var results = JSON.parse(this.response);

    }

    else

    {

    Xrm.Utility.alertDialog(this.statusText);

    }

    }

    };

    HttpReq.send(JSON.stringify({}));

    }


    You can then retrieve the updated value via JS API call and use XRM commands to replace the updated value in the form

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans