Table of Contents
In this article, we will understand the basics of Sharepoint workflow, the life cycle of Sharepoint workflow and finally we will implement a simple workflow using the three-state work flow which is available in Sharepoint.
You can download my 400 .NET FAQ EBook from http://www.questpond.com/SampleDotNetInterviewQuestionBook.zip.
For more resources on sharepoint tutorial videos visit http://www.learnsharepointtrainingtutorial.net.in
Quick Start FAQ Part 1
11 basic FAQ questions, a must for every newcomer. It's the basic Quick Start FAQ tutorial which talks about What is SharePoint, WSS, MOSS, Site/Site collection, Virtual Path provider and then ends with explaining Site Pages and Application pages.
Quick Start FAQ Part 2
This is the second part in the series which explains the ready made functionalities, custom pages, deploying/activating/deactivating features and lot.
Quick Start FAQ Part 3
This is the third part of the series in which we have explained page templates, page instances, WSS model, understand safe mode processing and deploy custom controls.
Quick Start FAQ Part 4
This series is all about webparts, webparts and webparts.
Quick Start FAQ Part 5
This is the 5th tutorial of SharePoint FAQ series. This series will mainly concentrate on custom columns, content types and document list library. I am sure once you read this article, your thinking of how SharePoint organizes document centralization will change.
SilverLight FAQ Part 1
This article talks about 21 important FAQ from the perspective of WPF and Silverlight. Both of these technologies are connected to a certain extent. This article not only explains the theory aspect of these technologies but also shows small samples for each of them
SilverLight FAQ Part 2
This FAQ is completely dedicated to animations and transformations using Silverlight. The tutorial starts with animation basics like timelines and storyboard. Later the article moves ahead to talk about different animations supported and we finally end the tutorial with a simple rectangle animation.
The first basic important point to note is Sharepoint workflow and windows are not different entities. The base for sharepoint workflow is windows workflow. In other words, Sharepoint workflow sits on the top of windows workflow and adds the human workflow flavor.
The below figure reflects the broader definition of Sharepoint workflow. It takes the core windows workflow from .NET framework and then applies content centric workflow on it. Content centric workflows are nothing but simple windows workflow attached to lists, documents and custom contents.
Figure: Content type workflow
You can visualize Sharepoint workflows as windows workflow with human workflow touch and feel. The human workflow touch and feel comes when the workflow is attached to a content type like list, document, etc.
For instance, let's say we have made approve and disapprove windows workflow. You can attach this workflow with a student content type and the human workflow for student then becomes student passed and student failed. If the content type is invoice, then approve workflow can become a invoice paid workflow and disapprove can become invoice not paid.
In other words, Sharepoint workflow is content centric and depicts human workflow.
Figure: Approve and Disapprove
Sharepoint workflow cycle is very much unique to Sharepoint environment. As we said Sharepoint workflows are always connected in context with a Sharepoint content like list or a document.
Figure: Four different stages in Sharepoint workflow
There are four stages in the Sharepoint workflow cycle -- associate, initiate, modify and complete.
Associate
As mentioned, workflows in Sharepoint are always talked about in context with a content type. So the first step is to associate a workflow with a content type like list or a document.
Initiate
The second step is to initiate the workflow instance. Workflows are nothing but classes finally so a workflow instance needs to be created to start the workflow in action.
Modify
Later the workflow instance is modified as per the workflow stages.
Complete
Finally the workflow object is terminated.
Figure: Screen and sharepoint workflow
The web forms of Sharepoint interact with WSS which in turn then interact with the windows workflow runtime. The windows workflow runtime passes details to the appropriate workflow instance depending on the data passed by WSS. The Sharepoint workflow instance then runs the workflow logic and takes appropriate action accordingly.
Three-state workflow helps organization to track workflows which has three states and two transitions. It's designed to track status of list item, task, etc. With each transition between states, the workflow assigns the task to some person and sends an email alert:
Figure: Three state workflow
In order to better understand three-state, we will create a simple task list. This task list will go through a review process. Following is how the workflow will be executed:
- Administrator initiates the task. The task is assigned to the reviewer.
- The reviewer then reviews the task, makes his comments and makes the task in progress. Once he makes the task in progress, it's automatically assigned to the acceptor.
- Acceptor finally does the complete review and closes the task.
Figure: Three state example
The first thing is to add two users in our computer domain, one is the reviewer who will review and the other is the acceptor who will close the task initiative.
To see the workflow, go to Site actions -> Site settings -> Workflows. You will see the Three-state’ workflow as shown in the below figure:
Let's first create a team site so click on Site actions -> Site libraries and lists -> create a new content -> Sites and workspaces and give some nice name like ‘My team site’.
Now click on ‘My team site’, click on tasks and then click on list settings as shown in the below figure:
Once you click on ‘List setting’, you will see a lot of options. Go to the permission and management section and click on ‘Workflow Settings’ as shown in the below figure:
You will be prompted to create a new workflow. So create a new workflow and you will need to fill in details of the workflow as shown in the below figure. Give a nice name to the workflow, for the current sample we have given the name as ‘My workflow’. We have specified that we create workflow as soon as the item is created.
A workflow will have three states: an initial state, middle state and final state. These states will be decided on the choice field of the task list. So when the status is having the value ‘Not Started’, then the workflow is in the initial state. When the status is with value ‘In progress’, then the workflow is in middle state. When the status is completed, that means the workflow object will be terminated and the workflow will be marked as closed.
Now the second step is to tell the three-state workflow what needs to be done on every workflow state. So let’s fill what should happen when the workflow is initiated. When the workflow is initiated, it will be allocated to the user ‘reviewer’. You can see the values visually in the below figure:
When the reviewer reviews the document, it’s assigned to an acceptor. So when the workflow is in the in progress state, it’s assigned to the acceptor for final closure.
So now that you have attached the work flow with the list, its time to invoke the workflow on the list. Click on new to add a task to the task list. Below are the details of task which we need to enter. What we have done is that we have entered a wrong statement with spelling mistakes.
Now as soon as you click OK, you will see that the task is assigned to a reviewer.
Now login as reviewer and click on ‘What is your name’ ?
Now as reviewer, you will correct the sentence and mark the task as ‘In progress’.
As soon as you mark the task as in progress, it’s assigned to the acceptor. Now login as an acceptor and mark the task as complete.
Once done, click on workflows and you should be able to see a complete tri-state flow.
You can see how the workflow was initiated, how the reviewer reviewed it and finally how the acceptor closed it.