function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rtvkgndertvkgnde 

prevent new values from record save

 I have a contract object, on which If any changes  are made and submit the record, the new values doesn't needs to be saved on the Contract object until the changes are approved via approval process. Once, the record is approved by the user!! It's when the changes needs to be updated to the Contract record. How can I achieve this?
Best Answer chosen by rtvkgnde
Raj VakatiRaj Vakati
You can do it two Ways .. 
  1. Save the data into Temp Custom object .. once its approved copy data into the Contact Object 
  2. Or You create a new Flag on the contact isPending Approved .. ( once its approved then check to true and show it ) . You can controll visibility of these records using critital based sharing or you can control edits using the validation etc 

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

If you create a custom field on your object, say, isApproved__c (checkbox, default to false), your approval process could update that field when the record is approved.
From there, you can wrap your desired trigger code in an if(record.isApproved__c && !trigger.oldMap.get(record.Id).isApproved__c) block to prevent that specific code from being run until isApproved__c is flipped from false to true (and you want to do the comparison against the old value as well, lest your code execute on every single trigger firing after it is approved).


Also check below threads for similar discussion.

http://www.forcetree.com/2009/06/how-to-check-whether-record-has-been.html
 
https://developer.salesforce.com/forums/?id=906F0000000949wIAA
 
https://salesforce.stackexchange.com/questions/143889/how-can-a-trigger-be-written-so-that-it-fires-when-a-record-is-approved/143895
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 
Raj VakatiRaj Vakati
You can do it two Ways .. 
  1. Save the data into Temp Custom object .. once its approved copy data into the Contact Object 
  2. Or You create a new Flag on the contact isPending Approved .. ( once its approved then check to true and show it ) . You can controll visibility of these records using critital based sharing or you can control edits using the validation etc 
This was selected as the best answer