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:
- Standard Contract
- 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:
- Standard Contract
- Non-Standard Contract
We need 2 site columns:
- Document Status
- Contract Status
We need a list to store the items.
- Custom List as type and Attach File feature is enabled
- The 2 content types above are associated
Additionally, we can have the following 2 workflows:
- Standard Contract Workflow
- Non-Standard Contract Workflow
The following will be the life cycle overview of a Standard Contract:
- A user creates an item
- Administrator signs the item
- User gets notified
- Workflow completes
The following will be the life cycle overview of a Non-Standard Contract:
- A user creates an item
- Accounting Department approves the item
- A standard item is created
- Standard workflow will continue
- Accounting Department rejects the item
- 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 Non-Standard Contract content type with the following columns.
The site column Document Status is of the type "Choice" with the values:
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.
Step 3: Create Workflows
Run SharePoint Designer 2010 and open our site. Click the "Workflow" pane on the left.
Click on the "Reusable Workflow" button from the toolbar.
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.
In the workflow designer, drag and drop the following condition and actions:
The steps say that:
- If current item > Document Status property is equal to Not-Signed
- Send an Email to Administrator
- If current item > Document Status property equal to Signed
- Send an Email to user who created the item
Save the Workflows and Publish it.
Step 4: Associating Workflows
Back inside SharePoint, open the List tehn select "List 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.
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.
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.
The Administrator can modify the Document Status value to "Signed" and update the item.
Then the workflow will send an email to the item creator as shown below.
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.
Create the Conditions and Actions as shown below.
Please note that the second If statement is doing the following activities on Approval:
- Send Email
- Create a new item in the Contracts list of the type Ordinary Contract
Additionally, use the "Add" button to add a Document Status column and set it to "Not-Signed".
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.
Step 3: Associate Workflow
Return to the SharePoint site and associate the workflow with the List content type.
Make sure you checked the item created and updated options.
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".
Enter the following information and save the changes.
The Accounting department should receive an email as shown below.
Edit the item and approve it.
Refresh the list page and you will see that a new item has been created with Not-Signed status.
Two emails will be triggered by the Standard Contract workflow, since a new item is created.
This completes our 2 workflow scenario. Now you can see a Non-Standard contract on approval creates a new Standard Contract.
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:
- One list named Contracts
- Two content types
- Two site columns
- Two designer workflows