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

How can I determine if a record used in Approval Process is locked

I have a Sample Request object that uses an approval process. I have created a Flex control that allows sales reps to quickly add products to the sample request. This control currently allows them to add products even after the record has been submitted for approval and has been locked for editing. I would like to query the status of the record to see if it is locked or not.

The only method I found was to go through the ProcessInstance relationship. The problem with this method is that there could be multiple ProcessInstances for each sample request (as it gets rejected, revised, and finally approved). I would have to go through all of the ProcessInstances and find the newest one, and then query it's status to determine whether the record is locked. I feel like this method is overly tedious.

Ideally there would be a field on the Sample Request object which lets me know whether a record is locked or not. But so far I haven't found anything like this.
Ron HessRon Hess
you could query the processinstances table, order by newest, limit 1
that should get the correct process request,
then check the status before adding products.
Thanks. I figured it would be something like that.



It looks like this can only be used to query the status of the ProcessInstance which is Started, Pending, or Approved.  Is there a way to determine whether a record is actually locked or not?


My use case is I have inherited an approval process that has left records in a locked state.  I need to find how many/which records are in this state.