A quick post to help anyone else that is using the SharePoint CreateTaskWithContentType or CreateTask workflow activity in their workflows or composite activities and get the following error in the ULS after starting the workflow via custom code:
“Item does not exist. It may have been deleted by another user.” with the error code 72ew and category “Workflow Infrastructure“.
The error reported through the UI in the list or library where the workflow was running is simply Error Occurred, so not very helpful.
The simple solution to this is that the item initiating the workflow must be checked-in.
I completely overlooked this when I was trying to debug why a workflow that was working perfectly well all of a sudden stopped and then I realised I had the item checked-out.
Moral of this story?
It’s a good idea to perform checks prior to custom code that starts a workflow containing an activity that requires a checked in item. Either that, or you could have the workflow automatically check the item in before executing any of these activities, but that would really depend on the business requirements as checking in items through code isn’t really advisable, so it’s better to ask the user to check the item in first.
Running the workflow from the out of the box context menu informs users to check the item in, so this is only required if you have a case where you initiate the workflow through code.