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 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:
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:
- 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.
![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:
- Send Email
- 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:
- One list named Contracts
- Two content types
- Two site columns
- Two designer workflows