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:
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.
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.
This is pretty handy. I have created tons of approval workflows but haven't bothered to customize the approval form for one of them, partly because I didn't know how. This is a great reference!
This type of functionality would be great for Microsoft to include OOTB in future versions. Having to go to multiple places for workflows is probably one of the most important problems to resolve currently I think. Thanks Laura!
Laura, will you marry me?
doesn't work for me.
I have all time the same item values displayed in the approval workflow task form
Every time Content of first item is showing in the task form of workflow.Can you help me how to filter exact content?
At step 15, make sure you uncheck that box. Then the query for the specific item happens at step 20.
is it also possible to edit it filed from here
Why I can't find the field "Related Content"?
This didn't work for me, because the URL being returned by the Related Content field was not in same format as yours. Mine was returning the title of the document, not the ID. In order to make this work, I had to use a substring after value of "expense\", and then set that value to the title field in the query.
I had some issues getting the data to filter properly and after a little tweaking I tracked down the cause. This is just a heads up for anyone following these instructions with InfoPath 2013 and SharePoint Online (via Office 365):
In step 20 you use the Related Content field to pull the URL for the data. This example URL given in step 20 is no longer current. The new URL format is: "https://sharepointsite/libraryname/filename.xml" ... because of this you need to make the following changes to the process:
Step 19: instead of ID, select "Title" - this is still in the data connection created earlier, under query fields.
Step 20: instead of "=" you will want to use "/LibraryName/" - substituting in your library name. If your form URL ends up being "contoso.sharepoint.com/Expense Reports/Document 1.xml" then you would use "/Expense Reports/" instead of the "="
Hope this helps someone!
please answer these two questions:
1) in step 20 you imply that a connection to the task list exists and the related content field is checked, is it correct? If not, I dont' know how to retrieve the related content.
2) I still get only the first item of the list and not the current item. The "retrieve automatically information" is disabled on the connection to the primary list. I tried enabling and disabling it on the "tasks" connection, but I still get only the first item. Please help me, I'm very next to the solution!!! :)
When the form returns to the manager he will not get the screen with approval.
And i did exact the same as this manual.
I think it is in step 20 where goes wrong?