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
  • Hi

    Currently, you can not set/overwrite the date_modified to a certain value. The 'date_modified = false' will tell the SugarBean not to update the date_modified field only.

    If you want to do that then I would suggest using after save logic hook using DB query instead of SugarBean save function.

    Kind Regards,

    Junaid

  • Is that a recent change?

    I have done several custom imports of data from other systems in the past and wanted to preserve the modified/created dates and modified/created users


    Working directly with the bean I successfully used:   

       //set a bunch of other values for the bean... 
       
       //set the create and modified to the original record's values
       $tbean->date_entered = $orig_created_date;
       $tbean->date_modified = $orig_date_modified;
       $tbean->created_by = get_sugar_user_id($orig_create_user_name);
       $tbean->modified_by = get_sugar_user_id($orig_modified_user_name);
       
       //these flags prevent the save process from overriding created by and modified by
       $tbean->update_date_modified = false;
       $tbean->update_modified_by = false;
       $tbean->set_created_by = false;
       $tbean->update_date_entered = false;
       $tbean->save();

    FrancescaS

  • The statement was based on my past experience with API. Never tried with bean save. Although if it is working with bean save then it should work with API but never worked for me in Sugar9.

Reply Children