July 8, 2016

Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation when deploying solution with workflow

I created the Workflow in SharePoint Designer 2013 and used "Save As Template" to export a workflow as WSP solution file into Site Assets library.  And then took the WSP file and deployed it to target environment.  However, when the workflow was updated, the "Feature" that enables/publishes the workflow was not activated in the target environment as previously. It was giving following exception: 

“Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation due to the following errors:
Failed to create a 'ListId' from the text '$ListId:Lists/configuration;'. HTTP headers received from the server - ActivityId: 4b8fd97c-7c0f-4b12-8038-247a513a3f00. NodeId: . Scope: . Client ActivityId : 6768869d-f0de-3000-2122-c09145073f7d. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at Microsoft.Workflow.Common.AsyncResult.End[TAsyncRe……..”

The "Elements.xml" file, which is packaged within the "WSP" solution file contains 2 different "<File>" elements. One <File> element represents the XAML file, and the other represents the Workflow association file. Comparing the Elements.xml file from a working solution file with the one which gives the specified error, I noticed that "WSPublishState" property value was different.  In the working solution file, WSPublishState value for each "<File>" element was "3" while in the failing version it was "1".

<PropertyName="WSPublishState" Value="3"/>

<PropertyName="WSPublishState" Value="1"/>
Note: WSPublishState property is also added within the "MetaInfo" tag in same file, so both occurrences should be updated.

Therefore, when the workflow files were published, due to different states it was corrupting the deployment process.

To resolve, please follow below steps:
1. Open WSP package using Project ->New Project -> ‘Import solution package’ from VS 2012/2013.
2. When solution is opened in VS 2012/2013, update the Elements.xml file.
3. Update the WSPublishState value for both "File" elements so they match. 

·       Note: Make sure you also update WSPublishState property within the ‘MetaInfo’ element if they differ. The actual value may matter (has not been tested); but if the values are both changed to "3" (to match the working version), then it works. Then again package the solution to create new WSP file, which will now deploy correctly.

The value of the WSPublishState corresponds to the 
Microsoft.SharePoint.WorkflowServices.StoragePublishState enumeration (viewed using Reflector):

internal enum StoragePublishState






If you have any questions you can reach out our SharePoint Consulting team here.

No comments:

Post a Comment