I have a workflow that runs a search, then iterates through each document in the search. There is an Assign Field Values action in the loop. In the case of a document that's checked out, it will try to assign the metadata, but since it's checked out, it will throw the "Document locked with a persistent lock" error, which has built-in error handling in Workflow Admin Console to retry every 6 hours.
As a result, it gets to that document, retries 50 times, then terminates the workflow almost 2 weeks after it started. This workflow runs daily and every instance is terminating 2 weeks later because of that one checked-out document.
It is important that this workflow finishes the day it started.
I tried putting in a try-catch block to catch the "persistent lock" action, but apparently an expected error that retries every so often does not count as an error, only a warning, so the block does not catch it.
I can change the error retry time to 1 minute or remove the retry completely, but the workflow is currently waiting the 6 hours and I assume that change will not be reflected until the 6 hours are up.
Is there a way I can handle this situation, ideally without messing with the 6 hour retry time?
A) Want to get the "stuck" instance for today to continue past the checked out document to the rest of the documents before the day is over.
B) Want to prevent this issue from happening in the future if a document is checked out.
Thank you
EDIT: I believe I have found a workaround for this
try { DocumentInfo di = (DocumentInfo)this.BoundEntryInfo; FieldValueCollection fvc = di.GetFieldValues(); //fvc.Add("Account Name","ddd"); fvc["Account Name"]="dadfdfdd"; di.Lock(LockType.Exclusive); di.SetFieldValues(fvc); di.Save(); di.Unlock(); } catch(Exception ex) { if(ex.Message.Equals("Document locked with a persistent lock. [9167]")){ throw new Exception("Cannot assign metadata because document is checked out."); } else { throw new Exception("Unable to assign metadata."); } }