Hi everyone,
Can anyone share a script to update calculated fields for a particular module please?
Thank you in advance
Hi everyone,
Can anyone share a script to update calculated fields for a particular module please?
Thank you in advance
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 Francesca Shiekh
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?
Hi Tony,
Let me take it up with engineering and see where we are with this request.
Keep you posted.
rafa
Hi Tony,
Let me take it up with engineering and see where we are with this request.
Keep you posted.
rafa
Hi Rafael Fernandes
It would be awesome if you got this one sorted, many will vote for you to be next CEO for SugarCRM
Hey Tony,
Thanks but no thanks, our CEO is doing an amazing job, I just don't fit there ..
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.
hi Rafael Fernandes
you mentioned engineering team found it could be 'expensive for the Bean save'
wondering if the option mentioned by Francesca Shiekh was considered and if also 'expensive'?
$bean->update_date_modified = false; $bean->update_modified_by = false;
.
CRM Business Consultant