Lookup fields and Repeating Sections - InfoPath Dev
in

InfoPath Dev

Lookup fields and Repeating Sections

Last post 07-05-2012 07:10 AM by AdamAustin. 14 replies.
Page 1 of 1 (15 items)
Sort Posts: Previous Next
  • 07-02-2012 05:50 AM

    Lookup fields and Repeating Sections

    I have a form:

    'Part no.' is a lookup field that has the following rules:

    So basically it auto-updates Part Description, Serial Number and Size when a Part No. is selected.

    The trouble i'm having is that when you insert a new repeating section and select a new Part No., the Part Description, Serial Number and Size fields in the new section get populated by whenever you chose in the very first section instead of by what you chose in the new section. How can I change this?

  • 07-03-2012 07:31 AM In reply to

    Re: Lookup fields and Repeating Sections

    Hi - I think InfoPath may have "helped" with the filter (the bit in the square brackets in your actions) in an unhelpful way. Open the first rule, and open the formula editor (the fx button next to the value field). You'll find a checkbox that will display the full XPath - check that box. Then copy the result, and paste the formula here. I'm guessing that IP used a full XPath to PartNo_x002e_ instead of a relative XPath.

    Hilary Stoupa

  • 07-03-2012 07:50 AM In reply to

    Re: Lookup fields and Repeating Sections

    Hilary, I think I have fixed it... although I'm not quite sure how it works:

    This is the XPath value now that it's working:

    xdXDocument:GetDOM("EP Parts List")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Part_x0020_Description[../d:ID = xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:PartNo_x002e_[. = current()]]

  • 07-03-2012 08:32 AM In reply to

    Re: Lookup fields and Repeating Sections

    So, this could be simplified:

    xdXDocument:GetDOM("EP Parts List")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Part_x0020_Description[../d:ID = current()]

    The current() function returns the current node - since you are in a repeating group, PartNo could have many instances. Your rule is on PartNo, thus current() refers this PartNo. :-)

    Hilary Stoupa

  • 07-03-2012 08:43 AM In reply to

    Re: Lookup fields and Repeating Sections

    That's fantastic, thanks!

    On a tangentially related note, I now have a calculated field that adds up all of the values in the 'Amount' column. It works great, but i'd like to set it up so the Submit button is hidden unless the value in the calculated field is the same as the value in the 'Total Number of Items received' box.

    I thought I could do this using conditional formatting, but the calculated field doesn't appear to exist in my list of fields...

  • 07-03-2012 09:02 AM In reply to

    Re: Lookup fields and Repeating Sections

    You are right - the point of a calculated field is to not have to add a field to the data source to display the results of a calculation.

    However, you can use the same calculation for your conditional formatting. Add conditional formatting to your Submit button. For the first drop down in the condition, select the Total Number of Items Recieved field. Set the middle drop down to is equal to. For the third dropdown, use a formula - and you can use the same "sum" formula you are using in your expression. Make sense?

    Hilary Stoupa

  • 07-03-2012 10:37 AM In reply to

    Re: Lookup fields and Repeating Sections

    It makes total sense, but it doesn't seem to work.

    I have a rule on the submit button so if Total Received is not equal to sum(amount), the Submit button is hidden. Here is the XPath of the sum(amount)

    sum(dfs:dataFields/my:SharePointListItem_RW/my:Amount)

    But it only seems to work in the first Amount field. It's not adding up all the Amounts from the repeating fields.

  • 07-03-2012 10:42 AM In reply to

    Re: Lookup fields and Repeating Sections

    Can you change the first dropdown of the condition to "The expression" and paste in the resulting XPath so I can see the whole condition?

    Hilary Stoupa

  • 07-03-2012 11:44 AM In reply to

    Re: Lookup fields and Repeating Sections

    dfs:dataFields/my:SharePointListItem_RW/my:TotalRecieved != sum(xdMath:Nz(dfs:dataFields/my:SharePointListItem_RW/my:Amount))
  • 07-03-2012 11:51 AM In reply to

    Re: Lookup fields and Repeating Sections

    So, if there are multiple Amount fields - there will also be multiple Total Recieved fields? Do you need to be comparing the total of both?

    Hilary Stoupa

  • 07-03-2012 02:38 PM In reply to

    Re: Lookup fields and Repeating Sections

    Nope, just the one Total Received field. It's not in a repeating section. I've attached the .xsn if that's any help!
  • 07-03-2012 02:55 PM In reply to

    Re: Lookup fields and Repeating Sections

    Well, actually - the field is repeating. You've just bound it to a non-repeating control. That doesn't change the fact that in the schema it is in a repeating group, a sibling of the amount node. Every list item you create with this form will have a separate "Total received" field.


    Hilary Stoupa

  • 07-04-2012 12:35 AM In reply to

    Re: Lookup fields and Repeating Sections

    Ah okay. I just assumed that would be the way to get the field to stop repeating every time a new item was created, as I only want one copy of Delivery Note Number and Total Number of Items Received in every submission of data.

  • 07-05-2012 07:05 AM In reply to

    Re: Lookup fields and Repeating Sections

    The data source is what's important - not the controls on the form so much. That is, it is the structure of the data source that determines the final data, does that make sense?

    Hilary Stoupa

  • 07-05-2012 07:10 AM In reply to

    Re: Lookup fields and Repeating Sections

    So I need to make all the repeating data come from one source, and the data that I only want one copy of come from a secondary source?

    For example, someone enters a delivery note number and the total amount of items received. I only want one copy of each of these per submission of data, so I should use a secondary data source?

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