A long
awaited feature has finally come to the SharePoint 2010 and the feature is
reusable workflows. In earlier versions we could not create reusable workflows.
We now can
create reusable workflow for a content type. Yes, there is one limitation which
is we can create a reusable workflows only for content types. So when we add
content type to list or library we get the workflow along with it which has
logic attached to it.
We will see
that in action. First we will create a content type, add that content type to
list, then we will create a very simple workflow of course a reusable one which
is attached to the content type that we will create and then we will see how
that works with workflow in a library.
So go ahead
and open SharePoint designer 2010. I am first going to create a site column and
content types can only contain site columns.
Click on New
site column, I am selecting Choice column and giving name and assigning to a
new group and add some data to it.
So now we
have site column in our site and we will now create content type.
Now create a
new content type.
Now you can
find it to the custom group that we gave
Now click on
content type and go to its settings page
Click on edit
content type columns and then click on add existing site columns from top left
And then
select our site column to include the column in the content type.
Keeping the
content type settings page open, click on administration web page from where we
will associate document template with this content type.
Click on
advanced settings, upload a document template. So now we have associated a
document template with this content type.
Now is the
time when we will add this content type to the existing document library.
Go back to
designer, in all lists and library open the library on which you want this
content type to be added.
Once the
library opens, click on content type settings and add the department category
content type to it.
Now we have
that document template available in the library. To see that you can open this
in browser and then see the library all items page and click on New.
Now open the
SharePoint Designer, connect with your site and click on Reusable Workflow.
Select
document content type, here we can select the content type on which we would
like to attach the workflow to.
Now check the
condition, that if the current field is equals to department category and
compare that with Marketing then log to history that marketing was selected.
And I have
then put if else condition for each department.
Save the
workflow and then publish the workflow.
Now it’s time
to associate this workflow with the content type. Being on the same workflow settings
page, click on associate to content type option from ribbon.
When you
click on it, the browser window opens which allows you to associate. Select
start this workflow on item adding.
Once you
create a document using the template, and when you save it, you can see the
workflow has triggered and then completed by saving the right information in
the workflow history list.
No comments:
Post a Comment