How to set date_modified through REST API

I want to set the date_modified field of Notes that I am importing through the REST API. However, I can't see any way to turn off the automatic updating of date_modified in the REST API, if I try setting update_date_modified to false this has no effect.

An example of data I am sending via an HTTP PUT:

{
   "update_date_modified": false,
   "date_modified": "2016-02-09T10:12:52.0000000"
}

The request works but the date_modified is set to the date of the request, not the value I set

Parents Reply Children
  • Yes  you are right, I looked to the code of SugarBean.php and there is no possibility to set the timestamp to the given parameter. The flag only says that it should be updated or not, means the old already existing timestamp will not be overwritten. That makes sense if you run some integration jobs which do not really change the data but perhaps add some information flags. With modern integrations the date_modified field is very often used as a timestamp for outstanding data synchronizations, so it makes no sense to allow manipulation by default. If you want to change that date explicitly by API you need an own API endpoint which does not use the SugarBean to update the timestamp but perhaps an SQL query.

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

  • Just out of curiosity, I went into the code and have a look at the SugarBean.php file. So you are right , the above-mentioned code will work and change the date_modified as on line 2101, it is setting the date_modified based on $prev_date_modified variable. As per line 2064, this variable will contain either the old date_modified or the one set by your code.

    Strange that it is not working via API as ultimately APIs are also calling SugarBean saveData function.