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

Record State Equals EDIT

The user would like a batch job to run at an unspecified intraval to clear a hidden field.  This could cause problems if it updates a record that someone is currently editing.  I have not found a posting that explains how to identify if a record is currently being edited.  Is that possible in APEX?   This is not a on a custom object or through a visualforce page. Just want to see if the Opportunity record is currently in th process of being modified.  IE..The user pressed the "EDIT' button.

I know that I can specify if my process is updating something.  How can I check the record is already being updated at the time I check.

I have seen postings about records being "locked" for an approval process that is not what I am referring to here.

I think instead for identifying which records are updating you can use, FOR UPDATE  in SOQL qurey with locks the record, do the task and then release the lock

Thank you for your response.  Your suggestion was tested before this question was posted. If an update to an object in EDIT mode is executed from an another job while an object is currently in EDIT mode it blows up.  The question is "How do you check if a standard object row is currently in EDIT mode from a batch process before you try to update it?"