SP 2016 OnPrem:
I'm using an API to do a custom upload to my Document library. After initial upload my script gathers basic info about the user to set default values and update the document properties. So the item is uploaded and saved a 2nd time almost immediately. Then I open the document properties immediately after that so the user can add more details, all within the same process. I have a 2013 workflow set to run on Update, so it's triggered on that 2nd save.
This causes a conflict error when trying to Save the document properties for the 3rd time (in the UI). (Because while I was opening the document properties the workflow was running in the background.) It's the same problem described here: Cannot save document properties with workflow enabled
I am able to get around that by deselecting "Automatically update the workflow status to the current stage name" in the workflow. That prevents the conflict but it also prevents my workflow from triggering on that UI save.
I have checked the End date in the workflow history and sure enough, it doesn't run for that 3rd save. However, if I close the document properties, reopen and save them again, the workflow will trigger.
So the problem has something to do with uploading via api, updating via api and opening the document properties in the UI all in one stroke.
It makes sense why the conflict would happen, but not why the workflow won't run if I deselect that option.
Any advice?
Thank you