Is there a way to tell if a record is locked by a ...
# suitescript
b
Is there a way to tell if a record is locked by a workflow via SuiteScript? I have a map/reduce that gets work orders with specific criteria using N/search and then loops through them to update a value after performing some other actions. The problem is that the script fails to update the value, and that makes the work order appear in the next run of the map/reduce. If I could filter out the locked work orders, then I could tell my script not to process those.
e
I don't think you can search for locked records, but if you can edit the workflow you could set a custom checkbox to indicate the record is locked (set the checkbox to true when locking the record) and then use that field for your search condition.
b
Interesting idea. I'd prefer not to modify the workflow if I don't have to as it's not mine. Even without using search, do you know of a way to tell if a record is locked another other way? Like maybe loading the record and checking a field value?
e
If you load the record and it's locked you'll get an error you can catch
👍 1
b
Excellent. I think that will work. Thanks!
It seems that record.copy works on locked work orders, but hopefully you're right about record.load not working