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
Prasad SPrasad S 

Lock Batch records

Hi, 
Is it possible to lock records which are being processed by Batch?
Or Is there a way to restrict the user from edit when the records are processed through batch?

Thanks in advance 
 

 

Best Answer chosen by Prasad S
Raji MRaji M
Hi Bajrang,

Follow the below steps - 
1. create one new field on Object say "Is Checked?"
2.Update this field to TRUE in your Batch Job.
3.Write a Validation Rule with code as below - 
  PRIORVALUE( Is_Checked__c) = TRUE && Is_Checked__c = TRUE

If someone tries to edit this record when Is checked = true, it will throw an error.

Raji M

All Answers

Raji MRaji M
Hi Bajrang,

Please find the below link for different ways to lock the record. I hope this might help you.
https://sfdcfanboy.com/2017/04/26/7-ways-to-lock-a-record-in-salesforce/

Thanks,
Raji M
Prasad SPrasad S
Hi Raji, 

Thanks for your response. I need to lock records in the Batch which is not mentioned in the link.

Thanks, 
  BM
Raji MRaji M
Hi Bajrang,

Follow the below steps - 
1. create one new field on Object say "Is Checked?"
2.Update this field to TRUE in your Batch Job.
3.Write a Validation Rule with code as below - 
  PRIORVALUE( Is_Checked__c) = TRUE && Is_Checked__c = TRUE

If someone tries to edit this record when Is checked = true, it will throw an error.

Raji M
This was selected as the best answer
Prasad SPrasad S

Thanks Raji

Will try the same