I’be been working through building InfoPath forms to streamline the approval process of some internal documents, and one of the project requirements is to display the date / time as well as comments of each person who approves a document.
I built a SharePoint Designer workflow which first computes the approval routing (which varies between 8 and 10 approvers depending on the value of some fields), then collects the approvals via the “Start Approval Process” task, and then emails up to 10 SharePoint groups based on a different set of criteria on each document.
SharePoint Designer Workflows store these “Assigned Tasks” in a Task List, which the developer is able to specify. Each Task in the Task List contains a HIDDEN COLUMN called WorkflowItemId which associates the Task with the Item against which the workflow is running. This column is a pesky little bugger for reasons explained below.
There is a blog post which describes one method for displaying all approvals tasks on the actual InfoPath form which goes roughly as follows:
- Create a new custom list containing all of the columns you need to reference
- Edit the “Behavior of a Single Task” for the Approval Process in question so that if the outcome is approved, add a new item to the custom list
- Add a Data Connection on the InfoPath form to pull data from the new custom list and display it on the form.
I didn’t want to go through the hassle of creating a separate list for each workflow I’m running, just to store data that’s already being stored in the associated Task List.
So, the big question: Why don’t you just add the Task List as an InfoPath Datasource and call it a day?
Well, the answer to that question may infuriate you: you are unable to filter the list according to the ID of the item in question because the attribute that stores the item id (WorkflowItemId) is forcibly hidden!
- InfoPath does not provide WorkflowItemId as an option in the Data Connection query path.
- CSOM CAML queries error out when you attempt to use WorkflowItemId as a query field, so the SOAP / REST Data Connections in InfoPath also fail.
Other than the solution above, there are really only two other options:
- [WARNING: Unsupported] : You could use SharePoint Reflection to un-hide the WorkflowItemId field, and then query it within InfoPath.
- Write a SharePoint Web Service that uses SSOM to query the Task List according to a parameterized input of the workflow item id, site name, and task list name.
I went the second route, and created such a web service, which is available here: https://github.com/bciu22/ApprovalTaskListService.
The result is that you can add an InfoPath Data Connection that looks something like this:
So that you can have a repeating table on your form with all approvals that looks something like this: