SharePoint Designer workflow logic fails to execute on InfoPath promoted fields.


Symptoms


SharePoint Designer 2007/2010 workflows can be associated with various types of SharePoint content. One example is an InfoPath form library. The user interface, for workflow creation, works just like any other SharePoint resource with one stipulation.

The InfoPath field promotion process and the workflow initiation process are asynchronous and there can be timing issues.

Consider the following scenario. The InfoPath form promotes fields to SharePoint columns. Let's further assume that the workflow relies on these promoted columns/fields for the logical execution of the workflow.

If the workflow starts on new item creation there is a chance that the workflow will fail to follow the normal execution one would expect.

The following error might be logged in the workflow summary page:

The item is currently locked for editing. Waiting for item to be checked in or for the lock to be released.

Cause


This occurs because the two process are asynchronous and do not wait for one to finish before the next starts. The workflow starts when a new item is added to the form library and the InfoPath field promotion process starts when the form is saved to SharePoint.

This is not necessarily limited to InfoPath promoted fields. This scenario should be kept in mind when working with any type of SharePoint data that promotes data to SharePoint columns.

Resolution


Depending on the complexity of the workflow there are a couple of solutions.

Solution 1

The first is to always have a Pause for Duration action at the start of the workflow. This will allow SharePoint to promote all the InfoPath form fields from to SharePoint columns and then the timer job will pick up the workflow during the next timer job cycle.

Solution 2

The second solution is a bit more complex. It involves using the Wait for Field to Change action and Pause for Duration action.

This tends to be leverage later on in the workflow execution if the InfoPath form fields are changed or new data is being promoted. The pairing of the two actions is done in order to avoid an indefinite pause and to allow for all the new form fields to be promoted.

Consider the following scenario. The InfoPath form has two regions, one for the Submitter and one for Managers. Using the first suggestion, the workflow is paused for 1 minute right at the start to allow for all the form fields to be promoted.

Then an email is sent to the Manager indication a form has been submitted. The email can contain all the promoted fields to save time.

Next, the Manager has to go into the InfoPath form to add comments and various other bits of data to approve or reject the form. This data will be promoted and a dynamic email will be sent out to the Submitter based on the Manager's input.

Now, this is where the Wait for Field to Change action comes in very handy. We can pick any of the columns from the Manager section to wait to not be empty or even to contain a specific word.

Once this condition is met the workflow will resume but the field promotion process might not be complete. This is why we follow the Wait for Field to Change action with a Pause for Duration action.

Once the workflow rehydrates from the Pause for Duration, the field promotion should be complete and the workflow logic can execute as intended.

NOTE: It's a good idea to require columns to have data otherwise trying to account for all the various scenarios that this introduces is very problematic with SharePoint Designer workflows.