Editor’s Note: The following is a guest post by SharePoint Server MVP Laura Rogers as part of the MVP Award Program Blog’s “MVPs for Office 365” series. Laura Rogers is a Senior SharePoint Consultant at SharePoint911 and has seven years of experience in SharePoint implementation, training, customization and administration. Her background is in server administration, and current focus is on making the most of SharePoint’s out-of-the-box capabilities. She works extensively with SharePoint Designer workflows, InfoPath and Data View Web Parts. Laura’s latest book on SharePoint 2010 is Beginning SharePoint 2010: Building Business Solutions with SharePoint. Her blog is www.sharepoint911.com/blogs/laura. Laura is currently working on a new book with Microsoft’s Darvish Shadravan, called Using Microsoft InfoPath 2010 with Microsoft SharePoint 2010 Step by Step. Twitter: @WonderLaura.
In the SharePoint Designer 2010 enterprise version, and in Office 365, there are three new workflow actions that use something called the Task Process Designer. The three new task actions in SharePoint are called Start Approval Process, Start Feedback Process, and Start Custom Task Process. When these are used, you are eliciting the new Task Process Designer.
In the example that will be used, there will be an expense report that needs to go through an approval process. When tasks are assigned in SharePoint, there’s always something, the thing that is being approved, and then the task that is being assigned. Sometimes, all of these different items and different places to click can be overwhelming to the end users. In this article, you will learn how to modify the task form so that it displays the pertinent metadata about the item that is being approved. When people look at a task that is assigned to them, they will be able to quickly see the information that needs approval, and click a button such as to approve or reject. With this kind of solution, there is no need for the users to open multiple windows.
The following components will be involved in the expense report approval solution:
- Expense Report – SharePoint list that contains all expense reports that Contoso employees submit for approval.
- Tasks – This is the task list on the SharePoint site. When people are sent expense reports to approve, all of the associated tasks live in this list.
- InfoPath Designer 2010 – This software will be used in order to modify the task form for expense reports that are assigned.
- SharePoint Designer 2010 – This software will be used to create the workflow that assigns tasks each time a new expense report is submitted.
The Expense Report
The expense report contains the following columns. For demonstration purposes, this form is extremely simple. A typical expense report, and most forms in general, will have many more fields.
The Workflow Steps
1. Open your site in SharePoint Designer 2010, and click Workflows on the left side.
2. Click the list workflow drop-down box, and create a new workflow based on the Expense Report list, and call it “New Expense Report”.
3. Since we want the employee’s manager to be the approver, inside of Step 1, add the action called Lookup Manager of a user.
4. Click this user, choose user who created current item, and click OK.
5. Add an action inside of Step 1, called Start Approval Process.
Note that this also creates a site content type called “Approval”, and when multiple ones are created, it adds parentheses such as “Approval (2)”
6. Click on these users. This is the interface where the approvers are added in order, and the task title and due date are set up.
7. Click the Address book icon next to Participants. Choose Workflow lookup for a user. Select the manager variable that was created in the previous step. Click OK twice.
8. Next to the task title box, click the ellipses button, which will bring up the string builder. Type “Expense Approval – “, and then select use the Add or Change Lookup button to insert the Created By field. Click OK twice.
9. For the instructions, type “Please look at this expense report, and approve or reject it”. For the duration per task, choose 1 day. Click OK.
10. Now, the workflow needs to be set up to run only when new expenses are submitted. Click the Workflow Settings button in the ribbon. In the Start Options section on the right, choose for the workflow to only be started automatically when an item is created.
11. Publish the workflow.
12. Now that the workflow has been published, notice something new. Still on the workflow settings page, take a look in the Forms section at the bottom right. There is a new InfoPath form called Approval.xsn. This is the task form for the task that gets assigned to the approver(s).
13. Click the name of the Approval.xsn file, to open it in InfoPath. The next step is going to be to display the associated expense report fields in the task form of the task that gets assigned.
14. Create a new data connection to receive data from the Expense Report SharePoint list. In the data connection wizard, choose the following fields and click Next.
15. Click Next. Name the data connection “Get Expense Reports”, and uncheck the box to automatically retrieve data when the form is opened. Click Finish.
16. In the Data tab, click the Form Load button to create a new form load rule. In the rules pane on the right, click the New button, and create a new Action rule. The goal here is to query the list of expenses in order to retrieve the one expense related to this particular task, so that the data can be displayed on the form.
17. Next to Run these actions, Click the Add button, and choose Set a field’s value.
18. Click the field picker box next to Field. In the Select Field or Group box, click the Show advanced view link at the bottom.
19. Pick the Get Expense Reports data source. Expand the queryFields section, and select the ID field. Click OK.
20. The goal here is to set a query value so that one specific record can be retrieved, instead of returning the whole list of expense reports and having to sift through them. In the task list, the only field that will have information about that original item that is being approved, is the Related Content field. The data in the Related Content field is simply the URL to the item being approved. So the matching information needs to be extracted from this. The format of a URL in an item in a SharePoint list is http://yoursite/lists/yourlistname/dispform.aspx?ID=_ The ID is what we’re looking for, so the substring after the equals sign can be extracted and compared to the ID field in the expense report list. So, still on the “Set a field’s value” screen, for the value box, insert a function.
Note that even though the formula says “WorkflowLink”, the field that I selected was “Related Content”.
21. Click OK twice. Back in the form load rules pane on the right, click the Add button one more time, and choose Query for data. For the data connection, choose Get Expense Reports, and click OK.
22. Now that the data about the expense report has been obtained, all you have to do is display it on the task form. In the fields pane on the right, click Show advanced view. Change the Fields drop-down box to Get Expense Reports. Expand the data fields section. There are the fields from the associated expense report. I find that the cleanest way to insert them on the task form is to use the Calculated Value field.
23. To take it a step further, you can customize the Expense Report form using InfoPath. Then, once the form looks the way you want, copy the form and paste it over into the task form, just to get the general look and feel and structure. Delete all of the fields, just leave the structure and labels:
24. For the Purpose field, put the cursor in the right cell, and on the Home tab in InfoPath, click to insert a Calculated Value. For the path, insert the field Purpose from the dataFields of the expense reports data source
25. Do the same thing for each of the other fields in the form, in their respective places. After each calculated field has been inserted, you can click on its Control Properties, and modify the Format As field, to format some as dates and some as currency, etc.
26. Click the Quick Publish button to publish the workflow form.
27. Test the solution by creating a new expense report. The workflow will assign a task to your manager. Open the task. Notice that when the manager receives this, it is not necessary to also open the original SharePoint list item, since all that is needed is the approval, and no changes are being made to the original item.
If necessary, the original item can still be opened by clicking the link to it at the top of the task. Also note that if other task processes are used on the same site, with the same task list, they will not be affected by this customization. This customized form only applies to the tasks associated with the expense report approval.
To read more about the task process designer, take a look at my article: “The SharePoint 2010 Task Process Designer” http://www.sharepoint911.com/blogs/laura/Lists/Posts/Post.aspx?ID=127.