Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

(0) ShareShare
ReportReport
Posted on by 7

Hi there, I have created a plugin which forces rollup field to recalculate when child records are either changed or created. The rollup field on parent immediately updates on the update step(child record being updated) showing new value.

BUT On the  "create step"(child record being created) I have to manually refresh the parent to see the new rollup field amount that has been changed by plugin, and has been dedicated to database. If I don't refresh the record the user still sees the old value. Want to automate this in the plugin.

Not sure what I am missing on Create, Post Op step? Any help greatly appreciated!! Tired of googling.

*This post is locked for comments

  • Carol J Kelly Profile Picture
    Carol J Kelly 7 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    Yes i understand now...Thanks. will add further refresh code.

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    The parent form doest refresh because the form is already opened and loaded the current values. Now the values are updated on server. In order to load these values, browser needs some action/action/event to be performed/ happend so that it connects to server again and loads the updated value. This event us generaly form load/refresh.

    The plugin is server side event which triggered from the form so thats why the browser forms reloads the updated value to the form but this happens on the form which triggered the plugin. In your case the plugin is triggering from a child so it can only update child entity for and not parent entity form.

    Hope this helps :)

  • Carol J Kelly Profile Picture
    Carol J Kelly 7 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    Hi Ravi.

    I dont understand why parent record rollup refreshes on update step using plugin. Rollup Data immediately reflects the database server change without having to refresh screen.

    On create step you were correct using postimage did not help. The new value has been committed to server, like in the update step. but unlike the update step it will not reflect client side ..not understanding why that is? If you can clarify why i will be at inner peace...lol

    So Yes i do have to either js refresh screen which I personally dont like or call an update so it only refreshes the field.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    Hi,

    It will not matter as the parent form is still opened in the browser. The problem is not the plugin, it is that the values are updated in the background so you need to refresh the form. You can automate this by writing sjavascript code to efresh the page when you add a new record on the subgrid.  

    Did you check the above link I shared? community.dynamics.com/.../279702

    Hope it helps.

  • Carol J Kelly Profile Picture
    Carol J Kelly 7 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    Yes exactly. The end users are creating records from the subgrid on parent.Perhaps on create step of plugin I should use Postimage and then recalc rollup?

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    Are these users creating the records from the subgrid on the parent form? Asking because it depends what all forms you have opened. As I mentioned above, because the values are updating server side, it won't show up unless the form is refreshed. The options you have is to add some kind of client script to refresh the form but then this is also depend upon how the child records are getting created.

    refer this thread: community.dynamics.com/.../279702

  • Carol J Kelly Profile Picture
    Carol J Kelly 7 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    Thanks but end user creates the child record. Code updates the  rollup field on parent record. If end user changes the already crested record new value shoss right away in parent. But when user creates new child in order to see the new value they have to refresh the screen. its a plugin no workflows are involved.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    Hi,

    Can you explain more on this "BUT On the  "create step"(child record being created) I have to manually refresh the parent"? Are you creating child records from a workflow? If yes is this workflow triggering on parent? If yes, is this real time? If yes, are you updating any value in this orkflow? If not, then try updating some dummy value from this workflow after your create step.

    It is expected that the form is still showing the old values cause to load the new values, you need to refresh. If you have a real time workflow then CRM auto refresh the record.

    Hope this helps.

  • Carol J Kelly Profile Picture
    Carol J Kelly 7 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    Yes that's what is happening but value only shows if I refresh the parent record. I would like not to refresh record. Code is below:

    Registered on both update and create of payment entity. Update refreshes parent right away and we can see the new value.

    Create is weird. The new value is there when screen is refreshed... why oh why.

    Entity SPdetail = service.Retrieve("newbtss_payment", targetentity.Id, new ColumnSet(true));

                   Guid SPID = ((EntityReference)SPdetail["newbtss_paymentsid"]).Id;

                   if (targetentity.Attributes.Contains("newbtss_paymentamount"))

                   {

                       Entity myEntity = service.Retrieve("newbtss_scheduledpayments", SPID, new ColumnSet(true));

                       CalculateRollupFieldRequest rollupRequest = new CalculateRollupFieldRequest

                       {

                           Target = new EntityReference("newbtss_scheduledpayments", SPID),

                           FieldName = "newbtss_amountpaidrollup"

                       };

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

                       myEntity = response.Entity;

                       var newtotal = myEntity.GetAttributeValue<Money>("newbtss_amountpaidrollup").Value;

                       tracer.Trace("New Rollup Total:", newtotal);

                       service.Update(myEntity);

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 1,019 Super User 2025 Season 1 on at
    RE: Plugin to Force Recalculate Rollup Fields- "on child create" have to refresh screen but not on child update

    Hi Carol J Kelly,

    You need to update the parent record when the child record is created. This topic mentions other approaches for solving this problem.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans