Friday, May 20, 2011

Create SharePoint 2010 workflow using SharePoint Designer

In this article, I'd be discussing about the creating SharePoint 2010 workflows using SharePoint Designer 2010. Rather than designing a workflow from scratch, I'd be re-using the workflow defined in Visio (Refer previous article).

Before getting into the workflow, I'm defining a content type by name ‘Invoice Report’ with three basic site-columns InvoiceAmount, Invoice Date and InvoiceDepartment to keep it simple.

site columns

content type

Create a new custom list by name ‘Invoice’ and attach the content type ‘InvoiceReport’ to it.

list

Navigate to Site Objects –> Workflow in SharePoint Designer

import from visio1[6]

Choose ‘invoice processing.wvi’ (workflow designed in the previous article) and click Next.

import from visio2

Choose ‘Reusable workflow’ as type of workflow (in this case i want this workflow to be re—used across lists that has associated invoice report content-type).

import from visio3

Click finish.

The workflow will look like the following in the designer.

workflow designer

Go to step ‘Log for starting’ and change the message to ‘workflow is starting’'.

Go to If statement under step ‘Invoice > 50K’ and define the expression like if Invoice Amount less than or equal to 50,000.

image

image

Set Workflow status to Approved under If loop.

image

Under log for Auto Approval, set the message ‘Workflow is Auto Approved’.

image

Go the Else part and configure the Task Approval process.

approval config

In this case, the Task Approval process will be executed if the invoice amount is greater than 50,000. The idea is to enforce a manual task approval process, approved by the manager.

The workflow design would look like the following:-

final workflow design

If you choose Custom Approval Process or Custom Task Process, you’ll get bunch of actions to customize the behavior of the single task or task process.

task behavior1

task behavior2

The Task Behavior Actions is one of the improved feature in SharePoint 2010 workflows. The Task behavior actions does not appear in Visio 2010, when you design workflows . It is available in SP Designer 2010 and VS 2010. The actions like Escalate Task may find a common usage. But in this case, I'm not customizing any task behavior, just sticking with the task behavior defined for the Approval Process in SP Designer 2010.

Check for errors and publish the workflow.

Go to the SharePoint site and associate the Invoice Processing workflow with the invoice list.

Under workflow settings –> Add a workflow

Set content type to ‘Invoice Report

Select ‘invoice processing’ under the workflow template

Set ‘Department Invoice workflow’ for the unique name of the workflow.

Set the workflow to be started manually

workflow setting

Create an invoice item in the list.

invoice new item

Start the workflow manually.

The invoice item would be approved, because the amount is less than 50K.

image

Let’s try with another invoice amount of 60, 000.

Start the workflow again.

Now the workflow is not auto-approved, task is assigned to the Manager and it is in progress state.

Log in as Manager to see the assigned Task.

task approval

Click ‘Approval’ button to approve the invoice.

We’ve created a very simple workflow in SharePoint Designer 2010.

No comments: