SharePoint 2010 Real-World Workflow Scenario With 2 Contracts

In this article we can go through a real-world scenario involving signing, emailing, converting, content types and workflow.

Scenario

We have the following 2 types of Contracts:

  1. Standard Contract
  2. Non-Standard Contract

A Standard Contract is created by a user, signed by an Administrator and gets completed.

A Non-Standard Contract is created by a user, approved by the Accounting Department, and then converted to a Standard Contract and the Standard Contract procedure is followed.

Solution Design

In the SharePoint terms, we can think of the following 2 Content Types:

  1. Standard Contract
  2. Non-Standard Contract

We need 2 site columns:

  1. Document Status
  2. Contract Status

We need a list to store the items.

  1. Custom List as type and Attach File feature is enabled
  2. The 2 content types above are associated

Additionally, we can have the following 2 workflows:

  1. Standard Contract Workflow
  2. Non-Standard Contract Workflow

The following will be the life cycle overview of a Standard Contract:

  1. A user creates an item
  2. Administrator signs the item
  3. User gets notified
  4. Workflow completes

The following will be the life cycle overview of a Non-Standard Contract:

  1. A user creates an item
  2. Accounting Department approves the item
    • A standard item is created
    • Standard workflow will continue
       
  3. Accounting Department rejects the item
    • User gets notified
       
  4. Workflow completes

Workflow 1

The following is the procedure to implement the solution for Workflow 1: Standard Contract

Step 1: Create Content Types

Open the Site then delect "Site Settings" > "Site content types page".

Create the Standard Contract content type with the following columns.

Create the Standard Contract

Create the Non-Standard Contract content type with the following columns.

Create the Non-Standard Contract

The site column Document Status is of the type "Choice" with the values:

  • Unsigned
  • Signed

The site column Contract Status is of the type "Choice" with the values:

  • Submitted
  • Approved
  • Rejected

Step 2: Create the list

Create a new Custom List and name it "Contracts". Open the List Settings then select "Advanced Settings" > "Enable management of content types". From the List Settings add the preceding 2 content types to it.

Create a new Custom List

Step 3: Create Workflows

Run SharePoint Designer 2010 and open our site. Click the "Workflow" pane on the left.

Create Workflows

Click on the "Reusable Workflow" button from the toolbar.

Reusable Workflow

Here we are creating a reusable workflow for the Standard Contract content type. Enter the name of workflow in the dialog box that appears and choose the appropriate content type.

creating a reusable workflow

In the workflow designer, drag and drop the following condition and actions:

workflow designer

The steps say that:

  1. If current item > Document Status property is equal to Not-Signed
    • Send an Email to Administrator
       
  2. If current item > Document Status property equal to Signed
    • Send an Email to user who created the item

Save the Workflows and Publish it.

Workflows and Publish

Step 4: Associating Workflows

Back inside SharePoint, open the List tehn select "List Settings" > "Workflow Settings"

Workflow Settings

Select the Standard Contract and Standard Contract Workflow and enter a unique name as shown above.

Scrolling down, make sure you checked the following 2 check boxes for invoking the workflow on item creation and updating.

workflow on item creation and updating

Click the "Ok" button to save the changes.

Step 5: Testing the workflow

Now create a new item of type Standard Contract in the list.

Standard Contract in the list

On saving the item, the workflow will be automatically started and the Administrator should receive an email. I am using the SMTP4DEV tool for capturing emails generated from SharePoint.

emails generated from SharePoint

The Administrator can modify the Document Status value to "Signed" and update the item.

Document Status

Then the workflow will send an email to the item creator as shown below.

send an email in Workflow

This confirms the Standard Contract workflow.

Workflow 2

The following is the procedure to implement the solution for "Workflow 2: Non-Standard Contract".

Step 1: Create Content Types

We have already created the content types and site columns for this workflow.

Step 2: Create Workflow

Open SharePoint Designer 2010 then select the "Workflow" pane > "New Reusable Workflow".

Enter the workflow details as shown below.

New Reusable Workflow

Create the Conditions and Actions as shown below.

Create the Conditions and Actions

Please note that the second If statement is doing the following activities on Approval:

  1. Send Email
  2. Create a new item in the Contracts list of the type Ordinary Contract

Ordinary Contract

Additionally, use the "Add" button to add a Document Status column and set it to "Not-Signed".

Document Status column

This action will ensure that the new item will have the Not-Signed status and the Standard Contract workflow will start automatically for Signing by Administrator.

Save the workflows and publish it.

Save the Workflows and Publish

Step 3: Associate Workflow

Return to the SharePoint site and associate the workflow with the List content type.

SharePoint site and Associate the Workflow

Make sure you checked the item created and updated options.

workflow on item creation and updating

Click the "OK" button to save the changes. Now the workflow is ready. We can test the Non-Standard scenario.

Step 4: Test Workflow

Open the list and choose the "New" tab > "New Non-Standard Contract item".

New Non-Standard Contract

Enter the following information and save the changes.

Save change

The Accounting department should receive an email as shown below.

Accounting department email

Edit the item and approve it.

Edit the item and approve

Refresh the list page and you will see that a new item has been created with Not-Signed status.

Not-Signed status

Two emails will be triggered by the Standard Contract workflow, since a new item is created.

emails to Standard Contract workflow

This completes our 2 workflow scenario. Now you can see a Non-Standard contract on approval creates a new Standard Contract.

Note.jpg

As you have observed, if we are developing the entire functionality from scratch, it will take at least one week of time. SharePoint did that in just 10 minutes.

References

http://technet.microsoft.com/en-us/library/cc263148(v=office.14).aspx

Summary

In this article we have explored a real-world scenario involving list, content types, and designer workflows. The SMTP test tool can be downloaded from:

http://smtp4dev.codeplex.com/

To summarize the article, we have:

  1. One list named Contracts
  2. Two content types
  3. Two site columns
  4. Two designer workflows

Up Next
    Ebook Download
    View all
    Learn
    View all