Adding the List Data to a Task Form in InfoPath 2010

Viewing Initiation Lists Data as a Secondary Data connection on a Task Form using InfoPath 2010 in SharePoint 2010

  1. Building business processes in SharePoint usually requires assigning tasks at stages for users to approve, enter data, or move the process along somehow.
  2. Problem: Assigning a task to someone creates another object, separate from the original list or document library, which can confuse users.
  3. Solution: View external data, like the list that fired the workflow, inside the form that is created for a task.  This is accomplished in InfoPath 2010.


  • SharePoint Server 2010
  • InfoPath 2010
  • SharePoint Designer 2010
  • Ensure that Workflow Features are Enabled in your site


This is an example of how to accomplish this.  I am keeping this simple as you can adjust this later for your needs.

  1. Use a list in SharePoint 2010.  If you need to create a custom list in a test area and populate it with some fields.  We are only going to be using Title and ID in this example, again simple.  I created a Custom List and named it: "SampleList".
  2. Open the site where this list exists in SharePoint Designer 2010.
  3. Create a List Workflow on this list.  I named mine: "ApprovalTest".
  4. In the first step, click Action -> Start Approval Process.
    Figure 1: Adding the Approval Workflow Process
  5. Assign it to yourself.  Give the email notification a Subject and a Body, but you can put a word in each for simplicity.
  6. Publish the Workflow.
  7. Go to All Files -> Workflows and open the folder for the workflow.  It should look like Figure 2.
    Figure 2: These are the actual files for a workflow.
  8. Click on the task form, in this case it is Approval.xsn.  (The name will match whatever you call the Action added in step 4, shown as: Start Approval process on Current Item with these users)

  9. Click Edit File, see Figure 3.
    Figure 3: Editing an InfoPath from in a Workflow
  10. Open the Data menu in the ribbon.  Choose From SharePoint List in the Get External Data section.
  11. Enter the site you created the list in.
  12. Select the list.  In this case it is SampleList.  Click Next.
    Figure 4: Select the List/Library you want to Bring data in from
  13. Select the Fields you want to have access to.  For this example we only need to add Title.  Sort can be left as ID, because we will be filtering the results by a single ID for the row that fires this Approval Process, so sorting on 1 item doesn't matter.  Click Next.
  14. Do not select the checkbox.  Storing a copy of the data in the form template for a SharePoint list or library would be slow.  Click Next.
  15. I would leave the name for the data connection alone.  UNCHECK the box for: Automatically retrieve data when form is opened.  (We will create a rule on form load that queries the data for us so we can choose to filter it by ID).  Click Finish.
  16. In the ribbon, Select Form Load in the Rules section.
    Figure 5: Form Load Rule
  17. Click New -> Action.
  18. Under the Details for: (enter a good name), I use "Load SampleList Data". See Figure 6.
  19. Under Run these actions, select Add -> Set a fields data. See Figure 6.
    Figure 6: Rules Settings
  20. Click on the field button menu at the right (see Figure 7), in this case we need to set the ID of the Secondary Data Source we added, SampleList.
    Figure 7: Select the Field menu.
  21. The next window pops up, select advanced view at the bottom.  Select your data connection in the drop-down menu at the top.  In this case it is SampleList (Secondary).  Choose the queryFields node, then ID (see Figure 8).  This will allow us to set the ID field using information from the current Task.  Click OK.
    Figure 8: Choose the ID field.
  22. Next we need to select the Value, by clicking on the Fx function button on the right. (see Figure 9)
    Figure 9: Value and Function settings.
  23. This brings up a Formula window.  Select Insert Function... button (see Figure 9), substring-after.  Click OK.  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 list.
    Figure 10: The formula we will use to Set the ID.

  24. Notice in Figure 10 we can double-click the fields, click the first and select Advanced View, Make sure the datasource drop-down is on Main, select the dataFields node, then Related Content. After you select the Related Content field and click OK, it calls it WorkflowLink. Related content is a link back to the item this task is related to, and it is a URL with the ID for that item at the end.  We will be stripping away everything but the ID.
    Figure 11: Selecting the Related Content field.
  25. Replace the second parameter in the substring-after formula to "=".  It should look like Figure 12.

    Figure 12: Completed Formula

  26. Click OK on the formula window.  Then click OK on the Rule Details window.
  27. On the Rules menu, Select the Add drop-down in the Run these actions section.  Choose Query for Data.
  28. In the Rules Detail popup window, in the Data connection, choose your list secondary connection.  In this case it is "SampleList".  Click OK.
  29. Now we have 2 rules.  One that sets the ID field of the data connection we added to the ID of the item this task is related to.  Another that will query that data connection to bring in the fields.
  30. Edit the form to display the Fields from the list item.  The best way is to add a Calculated Value field from the Home ribbon menu Controls section, and point it to the queryField.  A popup menu appears, called Insert Calculated Value.  Click on the Fx function button.  Click the Insert Field or Group... button.  (see Figure 13)
    Figure 13: Insert Calculated Value windows.
  31. Choose the field you would like.  I will be adding the Title and ID fields.  (see Figure 14)  Make sure for the calculated fields you use the dataFields node and not the queryFields node.  Click OK twice.  Repeat for all fields that you want to bring in.
    Figure 14: Select the Calculated Field from your Secondary Data Connection.

  32. You can customize the look of the value field by adding a border with the Layout menu in the ribbon and right-clicking it and choosing Properties to format the value as currency, number, etc.  
  33. I customize the form to show things better.  Figure 15 below shows my sample form for this task.
    Figure 15: Completed Form with some Formatting.
  34. Publish the form.  Then open up the list and create a sample item.  I will Title it Test Item.  Click Save.
    Figure 16: Add a new item in the SharePoint list.
  35. Next we need to run our ApprovalTest workflow on this item, which I left as start manually.
    Figure 17: Run the ApprovalTest workflow.
  36. Click Start to start the workflow.
  37. I should get an email notification that the workflow has started and another email telling me a task is assigned to me to approve this item.
  38. Navigate to the Tasks list the workflow is using and open the task to verify the form is showing the details from the list inside the Task form.
  39. Success!

Future Ideas

Often times I create a list for a business process and then associate documents in a library using a lookup column.  I will also be testing whether or not I can view these documents in the task form as well, since in several case these documents are being approved as well as the list item (the list item is really the details and tracking the process of the documents).


  1. Hi Eric, Long time no see, was looking for something randomly and came across your blog ^ ^.

  2. Hi Eric,

    Thanks for this great article!
    It worked like a charm :)

  3. Thanks is really helpful for me .


Post a Comment

Popular posts from this blog

SharePoint Designer 2013 Approval Workflow with Comments

Change SharePoint server hostname and Web Application Names

SharePoint Search - Content Processing Pipeline Failed to Process the Item