I've found bit of a problem when running a workflow on a document library. When you click new document it'll open up microsoft word in this example. You write some stuff into the document then save it to the library. The workflow associated to the library, in this case a home grown approval workflow with start to run now that the list item has been created. The problem however is that the document is still open and thus checked out until the user closes word. If the first thing the workflow does is to set some of the other fields on this list item such as setting an approval status to "pending" then this will error. It errors because the document is checked out.
I've tried to get the workflow to wait for the document to be checked in but this is where I'm failing. I'm trying an OnWorkflowItemChanged activity and in the code of that checking that the change made was teh document being checked in, so after this I can then continue with the rest of my workflow. The problem is that this activity doesn't seem to pick up the check in event as a change. This kind of makes sense because closing the document which automatically checks it in doesn't actually change any of the item fields.
So I need to find some way inside of my workflow to detect the check in event, but until then wait where I am.