Skip to main content
I am currently working on a Workflow for National Pen. The workflow saves an Infopath document to a SharePoint library. However, if a user has the document currently open, the workflow errors out with an exception that the document is locked. I need to be able to catch the exception and retry the event until it succeeds.
I have the same problem. Any suggestions for this anyone?
Alright, did a little bit of investigating. You can catch the exception and run the process again if you wish, I ended up modifying my sharepoint action with the following code to retry to upload the document until it's either uploaded or 10minutes has passed.

' Call Web Service to Upload Document
' Start Loop to run a delayed response to upload '
Dim isError As Boolean = True
Dim i As Integer = 0
While (i < 10)
If Not SpsList.UploadDocument(Server, Site, Folder, _
File, oByte, True , ErrorMessage) Then
' Error Occurred in UploadDocument - Set to delay for 1 minute and try again
Threading.Thread.Sleep(60000)
i = i + 1
Else
isError = False
'break out of loop
i = 10
End If
End While

'check if document upload succeeded, throw error if it didnt.
If (isError) Then
Throw New System.Exception(ErrorMessage)
End If


Hope this helps.
Matt

Reply