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

  • Hi
    It would be awesome if you got this one sorted, many will vote for you to be next CEO for SugarCRM Blush

  • Hey Tony,

    Thanks but no thanks, our CEO is doing an amazing job, I just don't fit there Slight smile..

    But I did get a feedback from engineering about this.

    They've done some research and tried few approaches already, however, this is a complex and expensive operation for our Bean save.

    We as product team, have to think of all possibilities and ensure quality code for you all to deliver and do your own thing.

    Engineering is considering a GA solution but is not for near-term.

    For now, discussing internally, leveraging a custom solution by updating the database directly through scheduler and SugarQuery is your best bet at the moment.

    Hope this helps.

    SugarCRM | Principal Developer Advocate

Reply
  • Hey Tony,

    Thanks but no thanks, our CEO is doing an amazing job, I just don't fit there Slight smile..

    But I did get a feedback from engineering about this.

    They've done some research and tried few approaches already, however, this is a complex and expensive operation for our Bean save.

    We as product team, have to think of all possibilities and ensure quality code for you all to deliver and do your own thing.

    Engineering is considering a GA solution but is not for near-term.

    For now, discussing internally, leveraging a custom solution by updating the database directly through scheduler and SugarQuery is your best bet at the moment.

    Hope this helps.

    SugarCRM | Principal Developer Advocate

Children