Archive: Assign a Custom Content Type to Task Process in a SharePoint Designer 2010 workflow

This article was originally written in February 2012.  It is being reposted here as an archive.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SharePoint Designer 2010 has some awesome new features!  Two of my favorites are (1) the ability to copy and modify an out of the box workflow and (2) the custom task processes.

What I don’t love is the way SharePoint assigns names with spacing to these tasks that have “_X0028_” and “_X0029_copy” in it.  It can cause problems with importing the workflow into Visual Studio, referring to the content type in custom web parts, and as an architect, I just don’t like the way it looks too messy.  Plus, if I want to make changes to the task list or roll the task up in a web part, I don’t want to have to guess which task goes with which workflow.

Here is an example of what SPD does when it adds a custom task action to a workflow or when you copy out of the box (OOB) workflow:

SharePoint Designer 2010 Workflow - Custom Content Types

SharePoint Designer 2010 Workflow – Custom Content Types

And this is what I want it to look like:

SharePoint Designer 2010 Workflow - Custom Content Type Desired Name

SharePoint Designer 2010 Workflow – Custom Content Type Desired Name

And it’s not just aesthetics; I have certain fields that I want to be able to store in the task.  I know that I can assign them in the workflow task process, but I don’t want the end user to see them so I want them hidden.

Here are the steps:

  1. Create your custom content type at your parent site (or content hub).
  • Important note:  If you are going to be exporting your workflows to other environment (i.e. local to production) and you do not use a content type hub, I STRONGLY recommend creating these content types and any site columns associated with the workflow with code.  This will ensure that your GUID’s (custom ID’s) are the same across all environments.

–   I worked with a developer to create my site columns and content types for me since we are moving workflows across environments

–   If you do not have access to a developer, then you will need to replicate these steps in each environment to make sure the ID’s are correct for each.

  1. Optional Step: If you want the “Claim Task”, Custom Outcomes functionality, and the ability to Reassign or Request Changes that comes with the out of the box workflow tasks for Enterprise SharePoint, you will need to change the display and edit forms.  If not, you can skip this step.

Example of InfoPath display form vs .aspx display form

SharePoint Designer 2010 Workflow - InfoPath Form vs .aspx form

SharePoint Designer 2010 Workflow – InfoPath Form vs .aspx form

  • If you create the content type in Code, make sure the display and edit form properties include “_layouts/WrkTaskIP.aspx”
  • If you create the content type by hand (or did not assign a display/edit form specification in the code), open the content type in Designer and change the display and edit form to “_layouts/WrkTaskIP.aspx” under “Forms” on the right side of the screen.
SharePoint Designer 2010 Workflow - Forms

SharePoint Designer 2010 Workflow – Forms

  1. Create your workflow
  • Either Copy and Modify an out of the box workflow
  • OR Create a new workflow and add a custom task process – Start Approval Process, Start Custom Task Process or Start Feedback Process

–   (I have not tested this with the other task actions)

SharePoint Designer 2010 Workflow - Task Processes

SharePoint Designer 2010 Workflow – Task Processes

 

  1. Save the workflow, but do not publish it.
  • NOTE: If you have published it and have the odd-named content type, just delete that task form.  We will generate a new task form at the end.

–   This odd-named content type will exist in your Content types library until you delete it from there

  1. Open the custom content type you created in Designer and Copy the ID
SharePoint Designer 2010 Workflow - Task Content Type ID

SharePoint Designer 2010 Workflow – Task Content Type ID

 

  1. Go to All Files, Workflows, <WorkflowName> folder
  • Note: If the “All Files” folder looks empty, click on another folder, such as subsites, and select “All Files” again.
SharePoint Designer 2010 Workflow - Workflow Files

SharePoint Designer 2010 Workflow – Workflow Files

 

  1. Open the file that ends in  “.wfconfig.xml” and replace the following items:
  • Line 2: TaskContentType=”<ID>” with your custom content type
  • Line 4: ContentType Name=”<Name>” with your custom content type name
  • Line 4: ContentTypeID  = “<ID>” with your content type ID you copied from previous step
  • Line 4: WorkflowForm= “Workflows/<workflowname>/<contenttypename.xsn>” with your content type name (just the name of the form, leave the folder name as is)
SharePoint Designer 2010 Workflow - Replace Content Type Code

SharePoint Designer 2010 Workflow – Replace Content Type Code

Here is what it should look like (my content type is “IntakeReviewTask”)

SharePoint Designer 2010 Workflow - Replace Content Type Code

SharePoint Designer 2010 Workflow – Replace Content Type Code Result

*Line 2 not pictured

  1. Save the the xml file and go back to your workflow folder

 

  1. Hover over the file that ends in “.xoml” file and select “Open with”  -> “2. SharePoint Designer (Open as XML)”.

    SharePoint Designer 2010 Workflow - Open as XML

    SharePoint Designer 2010 Workflow – Open as XML

 

  1. Click (Ctrl+F) for Find and enter “ContentType” in the “Find what” box
SharePoint Designer 2010 Workflow - Find and Replace

SharePoint Designer 2010 Workflow – Find and Replace

  1. Replace the ContentTypeID=”ID” with your custom content ID

 

  1. CLOSE SharePoint Designer and re-open it.
  • Refreshing has not worked for me.
  1. Open Designer, open your workflow by clicking on “Workflows” and Save your file.   Click “No” if you receive any messages to replace your file.
SharePoint Designer 2010 Workflow - Do Not Replace

SharePoint Designer 2010 Workflow – Do Not Replace

 

  1. Publish your workflow.  The right side of the picture below shows my workflow after completing this process.
SharePoint Designer 2010 Workflow - Replaced Content Type

SharePoint Designer 2010 Workflow – Replaced Content Type

And Voila, no more messy names and you can use your custom content type for whatever you may need, displayed in a CQWP, for example.

Leave a Reply

Your email address will not be published.