xpathsharepoint-2010infopathinfopath2010infopath-2007

Repeating Table with Column From Secondary Source


I have been struggling with this all day. I have an Infopath form that is connected to two Sharepoint Lists.

SP List 1 (Project Charters):

SP List 2 (Project Weekly):

I am attempting to combine these two lists into 1 repeating table on a new form. The Weekly Title field holds the same values as the Charter Title field, so I can match using Titles. I have found some resources, with this being the best:

http://www.infopathdev.com/forums/t/21262.aspx?PageIndex=2

There is a sample toward the end that does exactly what I want, but it will not work with my setup. Here is what I get:

Infopath Problem

As you can see in the picture, the "From my weeklys" column is always the same, and this is the problem. It should match with the corresponding field highlighted in red two the left. This is the formula in the calculated field:

Weekly_x0020_Opportunity[Weekly_x0020_Title = current()/Charter_x0020_Title]

The logic is to return the Weekly Opportunity description, where the Weekly Title matches the Charter Title; however, it only ever returns the same description. The testing column was used to prove that current()/Charter_x0020_Title was producing the unique titles for that row.

I feel like I am really close. The 3rd charter is missing a description, because my Weekly does not have a 3rd charter, so this is working properly. I just need to figure out how to bring-in the proper description.

Note: I am hoping for an Out-of-the-Box solution without coding.

FULL xPATH

xdXDocument:GetDOM("Project Weekly")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Weekly_x0020_Opportunity[xdXDocument:GetDOM("Project Weekly")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Weekly_x0020_Title = current()/d:Charter_x0020_Title]


Solution

  • The problem is that the path inside your predicate (between the []s) is using an absolute path rather than a relative one. You need to use a relative path.

    This path (what you have now):

    xdXDocument:GetDOM("Project Weekly")
      /dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Weekly_x0020_Opportunity
      [xdXDocument:GetDOM("Project Weekly")/dfs:myFields/dfs:dataFields
         /d:SharePointListItem_RW/d:Weekly_x0020_Title = current()/d:Charter_x0020_Title]
    

    means "Get the first1 Weekly Opportunity field where any Weekly Title field in the Project Weekly data source has the value of the current Charter Title."

    Or in other words, get the first Weekly Opportunity field in the Project Weekly data source any time the stuff between the square brackets is true.

    This path:

    xdXDocument:GetDOM("Project Weekly")
      /dfs:myFields/dfs:dataFields/d:SharePointListItem_RW
      [d:Weekly_x0020_Title = current()/d:Charter_x0020_Title]/d:Weekly_x0020_Opportunity
    

    means "Find the first1 SharePointListItem_RW where its Weekly Title is equal to the current Charter Title, and then get its Weekly Opportunity field."

    So that's what you should use.


    1 I am oversimplifying a bit here by saying "first". That path selects all of the nodes where that path is applicable, and then when InfoPath evaluates it, it takes the first result.