Bennett Adelson Technical Blog

Bennett Adelson Technical Blog

Coercion Failed Error when Running a Workflow from a Document Retention Policy


Recently, I had a client that wanted to create a “document review” workflow that would run if a document had not been modified in the past year. The solution involved creating a simple SharePoint 2010 style workflow that would assign a task to review the document to the reviewer(s) defined in the workflow’s association settings. A document retention policy was created to run the workflow if the document had not been modified in the past year. The workflow worked fine when run manually. However, when the workflow was run from the retention policy it was failing with the error: “Coercion Failed: Input cannot be null for this coercion.”

Workflow-CoercionFailed

As it turns out there is a (minimally documented) web application property called PolicyUseAssocDataAsInitData that controls whether the workflow association properties are passed to the workflow when it is started from a retention policy. This property was introduced with an October 2011 hotfix for SharePoint 2010 (see http://support.microsoft.com/kb/2596584).

After setting this property the workflow ran as expected from the retention policy.

You can enable this property on a web application using the following PowerShell commands:

$webApplication = Get-SPWebApplication http://yoursite.url
$webApplication.Properties[“PolicyUseAssocDataAsInitData”] = ‘true’
$webApplication.Update()

NOTE: After setting the property you need to restart the SharePoint Timer service in order for the change to take effect.

 

Leave a Reply or Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: