2016-12-14

Setting Related Item on a SharePoint 2013 Worfklow's SingleTask

Sometimes when we design workflows it is necessary to set related item in SingleTask to something different than the default listitem. Default list item is the item on which workflow was started. So, lets say we start workflow on doc1.docx. Inside the workflow we define SingleTask. This SingleTask, when opened in SharePoint UI, will have, by default, a link to doc1.docx. Sometimes we would like this SingleTask to have related item which is different than that particular doc1.docx.

Microsoft has intended for this purpose SingleTask argument named RelatedContentLinkListItemIntegerId. Great, you just set the list ID and item ID and you have your problem solved. Wrong!! Setting this property will have no impact on related item. At least, not if you use default generated SingleTask activity.

The solution:
Setting RelatedContentLinkListItemIntegerId will only work if you delete a particular child element in workflow markup (XAML). So, first open your workflow in Code mode (Visual Studio View Code - F7). Then locate the SingleTask activity which you would like to configure. This should be p:SingleTask XML element. Delete p:SingleTask.RelatedContentLinkListItemId child elemet. Save your workflow and voila, it will change related item to whatever value you set it.