Tutorial :Sharepoint - A feature creating a list with a workflow : Possible?


I've exported a list definition with Sharepoint Solution Generator. This list is associated with a workflow. If I search for the name of my workflow in the generated "schema.xml" file, I find XML that looks like this :

<Field DisplayName="publicationWorkflow" Type="WorkflowStatus" Required="FALSE" ID="{2a2504e5-5ad0-4a9f-8bf4-15ca29e49e02}" SourceID="{4ee14f93-1f9b-4dcf-8e50-dd046dfe0905}" StaticName="publicat" Name="publicat" ColName="nvarchar1" RowOrdinal="0" Version="2" WorkflowStatusURL="_layouts/WrkStat.aspx" ReadOnly="TRUE">          <CHOICES>            <CHOICE>Starting</CHOICE>            <CHOICE>Failed on Start</CHOICE>            <CHOICE>In Progress</CHOICE>            <CHOICE>Error Occurred</CHOICE>            <CHOICE>Canceled</CHOICE>            <CHOICE>Completed</CHOICE>            <CHOICE>Failed on Start (retrying)</CHOICE>            <CHOICE>Error Occurred (retrying)</CHOICE>            <CHOICE />          </CHOICES>        </Field>  

Then I use a feature to regenerate the list with it's definition from SSG, but the workflow is never made, I have to go to the settings of the list and associate the workflow manually...

So my 1st question is : Is this possible to create a list associated with a workflow using a feature?

And my 2nd : if yes, how?


There is no default way to associate a Workflow to the List Definition, If you want to do you have to follow one of the following option

  1. Write a Feature Receiver and write code to associate the Workflow to the List.
  2. Another option is to create a content type and you can associate a workflow to that content Type using feature.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »