Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error - InfoPath Dev
in

InfoPath Dev

Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

Last post 08-10-2011 02:53 PM by Hilary Stoupa. 21 replies.
Page 1 of 2 (22 items) 1 2 Next >
Sort Posts: Previous Next
  • 08-10-2011 07:52 AM

    Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

     OK; I'm starting a new post as I'm trying this method now.  I have been going through the instructions and I'm getting stuck on page 14/15 where we need a rule to set the ID.  I have entered the formula:

    SharePointListItem_RW[number(Count)]/ID

    as well as

    SharePointListItem_RW[number(Count)]/@ID

    Where SharePointListItem_RW was selected from the template as the repeating table, Count was selected from the xml file and ID was selected from the SP fields.  Wasn't sure if I was supposed to leave the @ in there.  Here is the XPath for the first formula:

     

    xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[number(xdXDocument:GetDOM("ViewOptions")/Util/fields/Count)]/xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID

     

    The error I am getting is:

     

     Node-test expected.
    xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[number(xdXDocument:GetDOM("ViewOptions")/Util/fields/Count)]/-->xdXDocument:GetDOM<--("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID

     

    Not sure what to do from here.  BTW I am using InfoPath 2010.

     

    Thanks!

     

     

  • 08-10-2011 07:58 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

    Hey there:

    Try this:

    xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[number(xdXDocument:GetDOM("ViewOptions")/Util/fields/Count)]/d:ID

     

     

    Hilary Stoupa

  • 08-10-2011 08:11 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

     That validated fine; thank you!

     

    I don't know XML but is there a very brief explanation you could give me as to why that works but the other one doesn't?  How does it know that the last part comes from the SP List connection and not some other field named ID?

     

    Thanks!

  • 08-10-2011 08:34 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

    The [ ] square brackets indicate a filter, so you are basically taking your full XPath to your field, and adding a filter to it (saying, out of all the d:ID nodes, I'd like this one). In this instance, you are using a number - when the value from the other field is returned, it will be a number like 1, 2, 3.... so you are directly indictating which row you want by position. But it could also be a filter based on a node value, like [d:AnotherField = 'foo'], with the path to the field being relative. Create a formula to select a node and add a filter using the UI, then tick the box to show the XPath, and you'll see a similar syntax.

    Looking at the XPath in the formula editor is a great way to learn. Also, when creating conditional formatting - after you've used the UI to create the condition, change the first dropdown to "The expression" and you'll see the XPath for your condition.

    Hilary Stoupa

  • 08-10-2011 08:55 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

     Thanks; I'm in IP2010 and I don't see any choice in the UI to add a filter.  I just typed it in manually.

     

    As a follow up, when I get to the next step, Decrement Count (page 23),  it shows a field named Count under the Main data source but I don't have this.  I assume this is created in the steps on pages 8-9 (Add Rules to Form Options).  In IP2010 I don't have the Tools->Form Options choice but I went to Form Load and put in the rules there.  My rules are:

     Query for Data from my Approvals SP connection

    Set the xml Count field to count(SharePointListItem_RW), or in the XML: 

     

    count(xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW)

     

    Not sure if something here is why I don't have that Count field under my Main source but I guess I can't continue without it.

     

    Thanks again for all of your help!

     

  • 08-10-2011 09:53 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

    When you select Insert Field or Group from the formula editor, you should see a filter button on the bottom of the dialog that opens to allow you to select a node or group. This is present in all versions of InfoPath.

    Is there a reason you can't add a field named "Count" to your main data source? At any rate, from your previous question - it looks like you've added a secondary data source where you have a count field, can you not use that one for the next steps?

    In general, what you are trying to do is use rules to loop through your nodes - as long as you have a field with the original count that you can decrement, you should be fine.

    Hilary Stoupa

  • 08-10-2011 09:56 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

     The secondary data source is the ViewOptions XML that the documentation has me create.  I can try using that data source for the count field or I could manually add a field called Count to the main data source but I was just trying to follow along completely with the manual (http://www.infopathdev.com/files/folders/qrules/entry58577.aspx).  If I manually create a field how will it know how to get the actual count?

     

    Thanks!

  • 08-10-2011 10:02 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

     FYI, I just tried using the XML count and I think it does what it's supposed to.  I'm getting very close but I seem to have one more issue.  When I preview the form it correctly inserts the same number of items that I have in my SP list but the data in the other columns all comes from the first ID in the list.  I will try to troubleshoot that myself but if you have any ideas I always appreciate them.

     

    Thanks!

  • 08-10-2011 10:17 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

     Just for a little more info:

     

    - I have 5 items in my SP list

    - It puts 5 rows in my IP table with IDs of 5-1

    - It is loading all IP rows with the data from the SP row with an ID of 1

    - One of the columns is staying blank for all rows even though there is data in the list; this formula is the same as the others too

     

    Apparently even though the counter is decrementing correctly it is somehow not tying each row to the ID number at the time the row is populated.  I have no idea why the one field is blank.

     

    Not sure if you can help with that but thanks again!

     

     

  • 08-10-2011 10:32 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

    Any chance you can attach your template to a reply? Under the Options tab.... then I can maybe see what's up?

    Hilary Stoupa

  • 08-10-2011 10:47 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

     Unfortunately I think that would go against my company's policy though I will try to ask around if I can do that.  The actual data is completely fake but since it is on our work server I have no idea if It's permissable.  I realize it may be impossible to troubleshoot further without it but you have been a huge help already!

     

    Thanks!

  • 08-10-2011 11:24 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

    Give me the sample XPath you are using to set one of the values in your form - perhaps I can see from there.

    Hilary Stoupa

  • 08-10-2011 11:35 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

     The first rule is Set ID and here is the xpath:

    xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[number(xdXDocument:GetDOM("ViewOptions")/Util/fields/Count)]/d:ID

    then I have a rule to set each field:

    Year =  xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Year[xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID = current()/my:myID]

    Quarter =  xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Quarter[xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ID = current()/my:myID]

    etc

    I did figure out the blank column issue by looking at the xml like you suggested.  That is helpful even though I don't fully get it yet.  The only remaining issue is the fact that every row is showing the list item from SP that has an ID = 1

     

    BTW, I changed all of the Main fields to be prepended by "my" so I can easily see the difference.

     

    Thanks!

  • 08-10-2011 11:38 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

     Oh; also the last rule is the decrement count:

     

    xdXDocument:GetDOM("ViewOptions")/Util/fields/Count - 1

     

    I assume that works fine since the table populates with the correct amount of records.


    Thanks

  • 08-10-2011 11:53 AM In reply to

    Re: Copy SharePoint List Values to InfoPath Repeating Section Fields - Formula Error

    Try using relative XPath in places you currently have absolute:

    Year = xdXDocument:GetDOM("Approvals")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Year[../d:ID = current()/my:myID]

     

    Hilary Stoupa

Page 1 of 2 (22 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.