Disable updating Date Modified when making a REST API call

I'm making an API call from an external service to change a custom field in the Accounts module in Sugar 8.3. The difficult part is that, when the field is changed, I don't want the "date-modified" field to change. I think that one way to do this is to set up an API logic hook where something like this happens:

$Account = BeanFactory::getBean('Accounts', $Result['id']);

$Account->update_date_modified = false;
$Account->update_modified_by = false;

Here are my questions about this:

1) Does this approach make sense, or is these a better way to do this?

2) What type of an API hook should I use? Before_routing, after_routing, or before_filter?

3) The route used by the API call would look like this: <Sugar URL>/rest/v11/Accounts/<account id>.  How can I get the account id parameter from the request inside the API hook?

Thank you for any help!

  • In the current versions you can only tell the SugarBean not to update the date_modified field but not set it with a certain value. If you look to the code of SugarBean.php you see that there is no chance to overwrite it with any external timestamp.  

    If you MUST set the date_modified field of a record you should write any kind of logic_hook which changes the value after save on database level.

    Quotation from the documentation:

    Updating a Bean Without Changing the Date Modified

    The SugarBean class contains an attribute called update_date_modified, which is set to true when the class is instantiated and means that the date_modified attribute is updated to the current database date timestamp. Setting update_date_modified to false would result in the date_modified attribute not being set with the current database date timestamp.

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    SugarCRM Deutschland GmbH