[SalesForce] Does Upsert alway change the last modified date of the record

If I run an upsert on a theoretical 100 records, all of which already exist in Salesforce, but only 4 of which have changed field values, will the last modified date for every record be set to the date that the upsert was run as opposed to the date that the record was last changed during the upsert, resulting in 96 record not having their last modified date changed. My understanding is that upsert only change the last modified date of the records that had changed field values.

Best Answer

The last modified date of the every record will definitely change ,since an update of record will eventually happen even if field values are not changed .

If you need to explicitly code such scenarios ,i would definitely recommend to do an explicit update and update only those records whose field values have changed .

if(previous_value!=new-Value){
  //List for update
}else{
   //List for insert
}
Related Topic