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)

How to refresh Rollup Fields autumatically in Dynamic 365 ?

(0) ShareShare
ReportReport
Posted on by

How to refresh Rollup Fields autumatically in Dynamic 365 ?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    By default Rollup field are calculated every hour. You check the the frequency under the system jobs-

    dynamicscrmpros.com/changing-rollup-calculation-frequency-microsoft-dynamics-crm-2015

    If you want to on-demand calculation, you can use CalculateRollupFieldRequest sdk request.

    www.magnetismsolutions.com/.../microsoft-dynamics-crm-sdk-manually-calculate-rollup-fields

    You can also use the Dynamics 365 Workflow Tools which has step to calculate roolup field which can be used in workflows directly.

    msdyncrmworkflowtools.codeplex.com

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Hi,

    You can use in Plugin, Custom Action or other external process and use the the CalculateRollupFieldRequest, such as in the example below:

    CalculateRollupFieldRequest request = new CalculateRollupFieldRequest

    {

           Target = new EntityReference("bgx_seminar", seminarId), // Entity Reference of record that needs updating

           FieldName = "bgx_attendees" // Rollup Field Name

    };

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

    If you need to run this against all records of a particular type, you will have to do a RetrieveMultiple and retrieve all records, and then run the above code on every single record.

    Simple as that...

  • Suggested answer
    Yusi Profile Picture
    100 on at

    You can use plugin as suggested by one fellow here or you can use JavaScript to recalculate it for you and bring you the updated results on the spot !


    For later approach, you can use the code below ...

    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({}));

    }

    Once you trigger the above JS function, you can retrieve the updated value via JS API call and use XRM commands to replace the updated value in the form for better user experience

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

    You can use the default functionality - modifying the recurrence of Rollup Job.

    A good description is here on the blog.

    https://vjcity.blogspot.com/2019/06/how-to-change-frequency-for-rollup.html

  • Community Member Profile Picture
    on at

    I'm just wondering if there is an update to this.  I mean, the button is just sitting there on the form.  This is web development.  There has to be a way to just push the button!

  • Suggested answer
    AbdulBasit545 Profile Picture
    30 on at

    Follow the article. He has explained it with example

    mrabdulbasit1999.medium.com/update-rollup-field-at-onload-event-in-dynamics-365-using-javascript-a0a4e650d1d8

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