Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / All-Topics

SharePoint Quick Start FAQ Part 6 – Workflows, Workflows and Workflows

4.97/5 (23 votes)
3 Mar 2014CPOL12 min read 130.4K  
SharePoint Quick Start FAQ Part 6 – Workflows, Workflows and Workflows

Links of SharePoint article Part 1 to Part 5 and Video with are moved to the bottom.

SharePoint Quick Start FAQ Part 6 – Workflows, Workflows and Workflows

Introduction

What is Windows Workflow Foundation?

What is a Workflow?

What are different types of Workflow in Windows Workflow foundation?

Is SharePoint workflow same as windows workflow?

What are the different stages of SharePoint workflow life cycle?

What is a three-state workflow in SharePoint?

Does sharepoint only have three-state workflow ?

How can we create sharepoint workflow using sharepoint designer ?

How can we create custom workflow using VS 2005 and VS 2008 ?

Previous Share Point Quick Start FAQ

In case you are new to SharePoint, please start with the below video Learn Sharepoint in 8 hours: -

Image 1

Introduction

In this tutorial we will concentrate mainly on SharePoint workflows. SharePoint workflow sits on top of windows work flow and adds content centric work flow features. So we will first start with some basics on windows work flow and then move towards share point work flows. Finally we will see how we can create work flows using sharepoint designer and visual studio 2005 and 2008.

You can download my free ebook which 400 FAQ questions and answers for WCF,WPF,WWF,Silver light and many more technologies. http://www.questpond.com/SampleDotNetInterviewQuestionBook.zip

What is Windows Workflow Foundation?

WWF is a programming model for building workflow-enabled applications on windows. System. Workflow namespace has all the necessary modules to develop any type of workflow.

What is a Workflow?

A Workflow is a set of activities, which is stored as model and they depict a process. Below figure depicts clearly the difference between Workflow and Activity. Every task is an activity and group of activity depicts a complete workflow. Workflow is run by the Workflow runtime engine.

Image 2

Figure: -Work Flow Foundation Architecture

Workflow model can be written in pure .NET code, pure XAML or Mix of XAML and .NET Code. A workflow model is compiled and can execute under windows, ASP.NET, Web services or windows services application.

What are different types of Workflow in Windows Workflow foundation?

There are two basics type of workflow Sequential Workflow and State machines workflow.

A sequential workflow has clear start and finish boundaries. Workflow controls execution in Sequential workflow. In sequential execution, one task is executed after other. Sequential workflow is more rigid in format and execution path has a determistic nature.
A State machine workflow is more dynamic in nature. Workflow has states and the state waits for events to help it move to next state. In State machine execution path is undetermestic nature.

Below figure shows visual conceptualization of fundamentals. You can see in Sequential workflow the execution path is very determent. Shiv performs the entire task sequentially and these tasks are very determent. Now have a look at the second workflow. Every state goes to other state when it receives some external events. For instance when Shiv is seeing star trek there is an event of flashing news which triggers him to see the flashing new.

Image 3

Figure: -Sequential and State machine workflow


Is SharePoint workflow same as windows workflow?

The first basic important point to note is Sharepoint workflow and windows are not different entities.
The base for sharepoint workflow is window workflow. In other words sharepoint workflow sits on the top of windows workflow and adds the human work flow 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 work flow attached to list, documents and custom contents.

Image 4

Figure :- Content type workflow

You can visualize sharepoint workflows as windows workflow with human workflow touch and feel.
The human work flow touch and feel comes when the work flow is attached to a content type like list, document etc.

For instance let’s say we have made approve and disapprove windows work flow. You can attach this work flow
with a student content type and the human work flow for student then becomes student passed and student failed.
If the content type is invoice then approve work flow can become a invoice paid work flow and disapprove can become invoice not paid.

In other words sharepoint workflow is content centric and they depict human work flow.

Image 5

Figure :- Approve and Disapprove

What are the different stages of SharePoint workflow life cycle?

Sharepoint workflow cycle is very much unique to Sharepoint environment. As we said sharepoint workflow are always connected in context
with a sharepoint content like list or a document.

Image 6

Figure: -Four different stages in Sharepoint workflow

There are four stage in the sharepoint workflow cycle associate, initiate, modify and complete.
Associate: - As said workflows in sharepoint are always talked 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. Work flows are nothing but classes finally so a workflow instance
needs to be created to start the work flow in action.

Modify: - Later the workflow instance is modified as per the workflow stages.

Complete: - Finally the workflow object is terminated.

Image 7

Figure ;- Screen and sharepoint workflow

The web forms of share point interact with WSS who in turn then interacts with the windows work flow runtime.
The windows workflow runtime passed details to the appropriate workflow instance depending on the data passed by WSS.
The sharepoint workflow instance then runs the work flow logic and takes appropriate action accordingly.

What is a three-state workflow in SharePoint?

Three-state workflow helps organization to track workflows which has three states and two transitions. Its designed to track status of list item , task etc.
With each transition between states the work flow assigns the task to some person and sends a email alert about the task.

Image 8

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 creates the 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.



Image 9

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 initative.

Image 10

To see the workflow go to Site actions à Site settings à Workflows. You will see the ‘Three-state’ workflow as shown in the below figure.

Image 11

Let 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.

Image 12

Once you click on ‘List setting’ you will see lot of options. Goto the permission and management section and click on ‘Workflow Settings’ as shown in the below figure.

Image 13

You will prompted to create a new work flow. 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 work flow, for the current sample we have given the name as ‘My workflow’.
We have specified saying that create workflow as soon as the item is created.

Image 14

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 value ‘Not Started’ then the work flow 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 work flow object
will be terminated and the workflow will be marked as closed.

Image 15

Now the second step is to tell the three-state work flow what needs to be done on every work flow state.
So let’s fill what should happen when the work flow is initiated. When the work flow is initiated it will be allocated to the user ‘reviewer’.
You can see the values visually in the below figure.

Image 16

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.

Image 17

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 we have entered a wrong statement with spelling mistakes.

Image 18

Now as soon as you click ok , you will see that the task is assigned to a reviewer.

Image 19

Now login as reviewer and click on ‘What is your name’ ?

Image 20

Now as reviewer you will correct the sentence and mark the task as ‘In progress’.

Image 21

As soon as you mark the task as in progress it’s assigned to the acceptor. Now login as a acceptor and mark the task as complete.

Image 22

Once done click on work flows and you should be able to see a complete tri-state flow.

Image 23

You can see how the work flow was initiated , how the reviewer reviewed it and finally the acceptor closed it.

Image 24

Does sharepoint only have three-state workflow ?

If you install WSS then you will only see one work flow that is three-state workflow. But with MOSS you
will see 4 more workflows which cover almost all the scenarios you will ever need for a workflow.

Image 25

Workflow name

Description

Approval

Routes a document for approval. Approvers can approve or reject the document, reassign the approval task, or request changes to the document.

Collect feedback

Routes a document for review. Reviewers can provide feedback, which is compiled and sent to the document owner when the workflow has completed.

Collect signatures

Gathers signatures needed to complete a Microsoft Office document. This workflow can be started only from within an Office client.

Disposition workflow

Manages document expiration and retention by allowing participants to decide whether to retain or delete expired documents.

How can we create sharepoint workflow using sharepoint designer ?

Sharepoint designer helps us to create workflows and attach the workflows to a content type like list , document etc. In other words Sharepoint designer creates workflows and publishes the workflow on the sharepoint server site.

Image 26

To understand it better we will build a simple work flow of completed and incomplete tasks.
We will create two lists one is the incomplete tasks and the other the completes tasks. The workflow will flow something like this:-

• User will create a task and enter the status of the task.
• If the task is incomplete nothing will happen.
• Once the task is marked as complete. The task will be copied from incomplete task list to completed task list.
• The task will be deleted from the incomplete task list.

Image 27

So let’s understand the eight important steps we will need to create the above work flow using sharepoint designer.

Step 1 :- Create a team site .

Step 2 :- Create two task list one is incomplete task list and the other completed task list. To create task list click on site action à Create: - Add a new library list à create a task

Step 3 :- Start the Sharepoint designer.

Image 28

Step 4 :- Open the site in your sharepoint designer using click on file àopen site.

Image 29

Step 5 :- Go to workflows by clicking on file à new à SharePoint content and click ok as shown in the below figure.

Image 30

Step 6 :- This is a important step. In this step we define two important things first is this work flow will be attached to which list. Currently we have attached the work flow to incompleted tasks list. Second we need to define the events on which the workflow should be activated. For the current scenario we have considered two events one when the item is created and the second when the item is updated.

Image 31

Step 7 :- This is one more crucial step where we need to define on what condition the work flow will execute and what action should take place if the condition is true. So when a task status is completed then two actions will take place. First the task will be copied from the incomplete task list to the completed task list. Second the task is deleted from the incomplete task list.

Image 32

Once you click finish you can see the work flow created in the share point designer. This workflow is also published to the sharepoint server,

Image 33

You can see if the work flow is associated with the incomplete task list. Go to incompleted tasks à Settings à List settings à Workflow settings ,
you can see the work flow is attached to the incomplete task list.

Image 34

Step 8 :- Ok , now it’s time to see the work flow in action. So go to incomplete task list and create a task with status completed.

Image 35

Once you click ok you see the task for some seconds in the incomplete tasks list and then the task is copied to the
completed task list and deleted from the incomplete task list.

Image 36

How can we create custom workflow using VS 2005 and VS 2008 ?

Coming soon…..I was really tired in this question so left it for some other time. I promise I will update it soon.

Previous SharePoint QuickStart FAQ

• Quick Start FAQ Part 1 :- 11 basic FAQ questions , must for every new comer.It's a 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 SitePages and Application pages. http://www.codeproject.com/KB/aspnet/SharePoint.aspx

• 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. SharePoint2.aspx

• 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. http://www.codeproject.com/KB/aspnet/SharePointFAQ.aspx

• Quick Start FAQ Part 4:- This series is all about webparts, webparts and webparts. Quick Start FAQ Part 4

• Quick Start FAQ Part 5 :- This series will mainly concentrate on custom columns, content types and document list library. I am sure once your read this article your thinking of how SharePoint organizes document centralization will change. Quick Start FAQ Part 5

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)