The new Lock Record action can now lock or unlock a record while also specify who can edit the record while it’s locked.
How: In Flow Builder, add an Action element to your flow. In the New Action window, search for Lock Record, and then select Lock Record. Alternatively, select Lock Record action element by start typing in search box Lock Record.
Input Values
Action: Required. Specifies the action to perform on the record. Valid values are Lock and Unlock
Record ID: Required. The ID of the record to be locked or unlocked
Allowed ID: Optional. The ID of a user, group, queue. or user role record that represents who can edit the record while it’s locked
Considerations
1. An attempt to lock a record that’s already locked results in an error with the UNABLE_TO_LOCK_RECORD error code
2. A system admin, the user who locked a record, or someone who’s an allowed user for the locked record can unlock the record. An attempt by any other user results in an error with the INSUFFICIENT_ACCESS_OR_READ_ONLY error code
3. If a record is locked with this action and the record is submitted to an approval process, then the approval process overwrites the record lock, making the allowed users specified by this action to no longer being able to edit the record
4. The approval process can be interrupted when Lock Record action unlocks a record locked by the approval process
Example: Build a flow that will lock/unlock an account
To create the flow and button:
- Create a screen flow
- Create a recordId input variable in order to get the Id of the account triggering the flow
- Add a Screen element with a toggle element where the user will be able to choose if they want to lock or unlock the record
- Add a Lock Record action element with the following input values
- Action: a formula resource where its value will be Lock or Unlock, depending on the value of the above toggle element
- Record ID: the record id of the triggering account
- Allowed ID: no value. Only system administrators or users with modify all permission can edit this record while it is locked
- Add a fault path to the Lock Record action and connect to a Screen element where the error will displayed to the user if occurred
- Activate the flow

- Create an action that will trigger the flow on the account object
- Add the action on the account page
To test the solution:
- Open an account and click the button to lock it

- Edit the account with a non-allowed user. An error message is displayed preventing you from save the account

- Open a locked account and click the button to lock it again. An error message is displayed preventing you from locking and already locked account
