AnsweredAssumed Answered

MassUpdate all Quotes from server (via module post_execute)

Question asked by Richard Coleman on Apr 11, 2018
Latest reply on Apr 25, 2018 by Richard Coleman

Hi there,

 

We have numerous sites we're upgrading to 7.9, and as part of it, we've refactored a lot of custom logic into sugar logic as part of the sidecar quotes.

 

However, after we upgrade the site to 7.9, I seem to be unable to recalculate these values programmatically. This results in some of the values appearing incorrectly until a user saves the record.

 

I attempted to do what is advised in this post: Recalculating Calculated Fields en mass ( update ) « Sugar Developer Blog – SugarCRM 

The only difference is that I used sugarQuery to obtain the list of IDs. Here's what I did:

foreach ( $results as $record ) {
    $focus = BeanFactory::getBean('Quotes',$record['id']);
    $focus->update_date_modified = false;
    $focus->update_modified_by = false;
    $focus->tracker_visibility = false;
    $focus->save();
    echo "<br>Re-saved Quote $count of $length \n";
    $count++;
}

However, while I get the messages that the quote was re-saved, the value doesn't change.

 

I next looked at the MassUpdate API. However, this is obviously meant to be run from the client, as opposed to the server. While I can see that it instantiates an object from the SugarJobMassUpdate class, there doesn't seem to be a straightforward way to give this class a list of Ids to update.

 

I'm now wondering if I should just create an instance of MassUpdateApi, and provide it a new RestService, and the expected paramaters directly i.e.

 

$api = new MassUpdateApi();
$test = $api->massUpdate(new RestService(),array('module' => 'Quotes', 'massupdate_params' => array('uid' => array('ac2e49b0-17ca-11e8-8f8c-00163ef1f82f'))));

 

Is this not advisable? Is there another option I've not explored yet? Does anyone have any experience with server side mass-updates?

 

Richard

Outcomes