Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, November 28, 2011

How to associate a workflow to a custom contentType

If you want to attach your custom workflow to a content type (single, multiple or all of the content types.. below are samples..

Associate workflow with a single contentType
Notice the highlighted portion which is a ';' delimited two part entry.
First is the type of category and second is the id of the entity. In this example, the category is content type and I have specified the id of the content type that should be available for this workflow.

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Workflow
     Name="WFName"
     Description="This workflow will .."
     Id="532c0a2d-fa10-4dad-80a4-1069b2bd8e27"
     CodeBesideClass="Demo.Workflow.Workflow1"
     CodeBesideAssembly="$assemblyname$"
      InstantiationUrl="_LAYOUTS/DEMO/DemoForms/form0_Init.aspx">
    <Categories/>
    <MetaData>
      <AssociationCategories>ContentType;0x010100a945f312c7bd4a589d1489ca8307f24d</AssociationCategories>
      <StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl>
    </MetaData>
  </Workflow>
</Elements>



Associate workflow with a multiple contentType
notice that every set of category is seperated by the delimiter ';#'
<MetaData>
  <AssociationCategories>ContentType;0x010100a945f312c7bd4a589d1489ca8307f24d;#ContentType;0x0101009a30bd7a9c18447e9b806af9c0931b9c</AssociationCategories>
</MetaData>



Associate workflow with a all contentTypes
<MetaData>
  <AssociationCategories>ContentType</AssociationCategories>
</MetaData>



Associate workflow with a all contentTypes and Lists
<MetaData>
  <AssociationCategories>ContentType;#List</AssociationCategories>
</MetaData>

No comments:

Post a Comment