Recalculate Aggregate in Salesforce

edited April 24, 2019 in Questions

I have a problem.  I have an aggregate that aggregates the value of a formula field on child records.  The formula on the formula field has changed, so I need a way to recalculate all the aggregate and save the new values to the parent record in bulk within Salesforce.  Is there a way to do this with Skuid without having to manually call up every single parent record?


  • edited April 23, 2019
    Any suggestions?  No one has come across this problem before?  Most rollup tools have a force recalculate function.
  • Zach McElrathZach McElrath Principal Software Engineer Chattanooga, TN 💎💎💎
    edited April 24, 2019
    Johnny, I'm a bit confused from your description as to what you are trying to do. Let me try to repeat back to you what I'm hearing and let me know if any of the following are inaccurate:

    1. You have a custom Formula field on a child object in Salesforce, related to its parent using a Master-Detail relationship (or is it a Lookup in your case?)
    2. You have a Roll-up Summary Field on a parent object that aggregates the values from the Formula field from child records.

    Are these correct? Or do you have a regular Decimal / Currency / Percent field that you're using to store the aggregated values, and you are trying to manually populate the value of this field somehow whenever the formula field changes on any of the child records? If that is the case, then you should consider using one of the free / paid tools on the AppExchange for recalculating roll-ups on lookup fields, e.g. or

    Maybe I'm misinterpreting your problem though. 
  • edited April 24, 2019
    Hi Zach

    Thank you for your reply.  I'll try to elaborate:

    Within Salesforce on object claims, I have a lost days field (formula field that returns a number)
    Claims looks up to case
    On case, there is a field for the total number of lost days
    On the Skuid page, there is an aggregate that is calculating all the lost days from all the child claims and populating the total number of lost days on case.

    This all works fine, but now the formula on claims for lost days has changed, thus the value for the lost days in claim has also changed.  Therefore, the Total number of lost days on case is incorrect.  Since the rollup was done using Skuid (aggregate), I am unsure how to force a recalculation to update the total lost days on case for all case records in bulk .  If this was roll up usling declarative rollup lookup summaries, I would simply force a recalculation, but I don't see that functionality within Skuid.  
  • Zach McElrathZach McElrath Principal Software Engineer Chattanooga, TN 💎💎💎
    edited April 24, 2019
    So, by "in Skuid there is an aggregate", do you mean an "aggregate Model", and you're using some process in Skuid to take values from the aggregate Model and populate them on the lost days field on Case?

    To be honest, this seems like a concern that should be handled at the database level, rather than through Skuid --- unless you have fairly few Cases. What sort of data volume are you working with? i.e. how many Cases need to be updated? If you've got fewer than, say, 10,000 cases, it might be as simple as running a few lines of Anonymous Apex from developer console to mass modify the cases. But long term you probably want to look into converting your lookup field on Claim to be a Master-Detail and then converting the total number of lost days field on the Case object to be a true Salesforce Roll-up Summary field --- that way the aggregation will be handled automatically, at the database level, which is the most appropriate place for this sort of thing.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!