Script to update calculated fields

Hi everyone,

Can anyone share a script to update calculated fields for a particular module please?

Thank you in advance

Parents
  • If you look at the List View, there is an option for "Recalculate Values".

    That is part of the massupdate actions and the corresponding code can be found in 

    clients/base/views/massupdate/massupdate.js

    The action executes the 

    updateCalcFields: function 

    which as you can see from the code is just a mass save:

        /**
         * Called to allow admins to resave records and update thier calculated fields.
         */
        updateCalcFields: function() {
            this.hideAll();
            this.save(true);
        },
    

    In other words, to trigger a calculated field to update all you need to do is save the record.

    The down side is all your Modified by and Modified Dates will change on every one of those records, which is not necessarily something one would want to do when modified date is important for reporting purposes.

    But it is the cleanest and safest way to do this.

    FrancescaS

  • Thanks
    Indeed I forgot and should have mentioned the desire is to not change the modified by or date.

    I remember somebody on the old community mentioning this was possible and shared insights for the method and maybe even the script (was it Blake?) but can't find it.

    Have a customer with more than 300k of records in one module, so ideally this script could then be run in background or only run overnight on a scheduler.


    Ideally the Sugar product team could look into adding this much needed feature for the greater good? Kissing heart

  • Hi Tony,

    Let me take it up with engineering and see where we are with this request.

    Keep you posted.

    rafa

    SugarCRM | Principal Developer Advocate

Reply Children