24 Oct HOW TO CHECK WHETHER A RECORD HAS BEEN LOCKED IN THE APPROVAL PROCESS
Have you been wondering how to check whether a record has been locked? I thought there might be a field which says that. But I was not able to find any such field. Instead I found that ProcessInstance table can be used to find if a record has been locked. But that looks very tedious and complex.
How about a very simple way,
Step 1: Create a field (say FLAG) of type Checkbox. Set the default value to UNCHECKED.
Step 2: In your Approval Process in the INITIAL SUBMISSION Action, create a Field Update. Update the FLAG to TRUE.
Step 3: In your FINAL APPROVAL and REJECTION Actions, create a Field Update. Update the FLAG back to FALSE.
Step 4: And done!!!! You can now find whether a record has been locked simply by checking the FLAG value. Be it in your Apex Class or Visualforce Page.
“Explore – Techila Global Services, A Salesforce development company”