Tuesday, July 17, 2012

How to create a custom Workflow Task / SharePoint Server Workflow Task content type using Visual Studio?


If you are designing an Workflow and you want to create custom Workflow Task or SharePoint Server Workflow Task using Visual Studio interface then you'll need to make these two content types visible.

To make them visible I'm using the following PowerShell script:

$site = Get-SPSite "http://site/url/here"
$web = $site.RootWeb

# Workflow Task
$contentType = $web.ContentTypes["Workflow Task"]
$contentType.Group = "Custom Content Types"
$contentType.Hidden = $FALSE
$contentType.Update()

# SharePoint Server Workflow Task
$contentType = $web.ContentTypes["SharePoint Server Workflow Task"]
$contentType.Group = "Custom Content Types"
$contentType.Hidden = $FALSE
$contentType.Update()

$site.Dispose()
Then when you can add a new Content Type from Visual Studio and you will see the two Content Type in the list.

To revert these changes run this PowerShell script:
$site = Get-SPSite "http://site/url/here" $web = $site.RootWeb # Workflow Task $contentType = $web.ContentTypes["Workflow Task"] $contentType.Group = "_Hidden" $contentType.Hidden = $TRUE $contentType.Update() # SharePoint Server Workflow Task $contentType = $web.ContentTypes["SharePoint Server Workflow Task"] $contentType.Group = "_Hidden" $contentType.Hidden = $TRUE $contentType.Update() $site.Dispose()
Post a Comment