Solution: SharePoint 2013 workflow. Custom task outcome always sets to default value.

Hi,
Yesterday I stumbled into an issue. My custom task outcome of SPD 2013 workflow stopped to function properly. It set to default value regardless of the Task Outcome I set programmaticaly in my custom ASP.NET task form.

My task settings looked as follows:

130604_02

But when I pressed “Reject” or “Approve” button in my form, my ApprovalOutcome variable set to “Approved”. When I changed Default Outcome to “Rejected” this variable set to “Rejected” regardless of pressed button.

I spent some time trying to google the issue, but could find nothing except comments on Andrew Connell’s blog where Anuja Bhojani suggested some sort of workaround and mentioned that the issue appears when custom outcome column is created from code.

I continued the investigation and found out that my task list contained two columns with the same name (“Approval Outcome”). When I deleted duplicate columns it started to work as expected. So the solution in my case was very simple:

Solution: Check whether your workflow task list contains duplicate columns. If so then delete unnecessary copy and most likely it will start working.

If it is not your case, double-check whether you set “Task content type” and “Outcome Field” correctly.

Also make sure that you checked for duplicates in the task list your WF associated with and not in another similar one. You can check what task list your WF uses on the workflow settings page. At the same page you can open associated task list by pressing “Open task list” link.

130604_04

Why it happened in my case: I created my custom task content types programmatically. During some tests I deleted these content types from the task list, but fields remained. After that I created task content types programmatically again and new columns with the same names, but different guids appeared. After adding new content types to the task list it started to contain duplicate columns (because their IDs were different).

Hope it saves somebody some time :-).

2 thoughts on “Solution: SharePoint 2013 workflow. Custom task outcome always sets to default value.

Leave a Reply

Your email address will not be published. Required fields are marked *