Update fields from drop down not working - InfoPath Dev
in

InfoPath Dev

Update fields from drop down not working

Last post 03-26-2013 06:08 PM by Hilary Stoupa. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 03-24-2013 08:35 PM

    Update fields from drop down not working

    Hi, I have a drop down menu that I want populate some other fields when selected. The data is being drawn from XML tables but it's not working, nothing shows up in the field. I am trying to use the current() function when filtering the data. The Xpath looks like: xdXDocument:GetDOM("Contacts")/CONTACTS/COMPANY/CONTACTPERSON[. = current()] - So when you select a company, the contact person loads up automatically. Any thoughts? I am relatively new to infopath BTW. Cheers
  • 03-25-2013 07:29 AM In reply to

    Re: Update fields from drop down not working

     So - in your drop down, what is the field that is being used for the value? Is it ContactPerson? Your current XPath says "I'd like the CONTACTPERSON field from Contacts where CONTACTPERSON is equal to the field bound to the dropdown list". Is this being used in a rule or a default value?

    It would be helpful to know:

    1. Where the XPath is being used
    2. What the value field is in your dropdown control

    Or even just a description of the data you need. You can even just attach your template under the options tab if you want to make it super easy for me to give you a hand. :)

    Hilary Stoupa

  • 03-25-2013 04:03 PM In reply to

    Re: Update fields from drop down not working

    Hi Hilary, I have attached my contact XML tables and a screen shot of part of my form. As you can see, there is a drop down to select a company. When the company is selected, the contact person and their details needs to be loaded into the relevant fields. I hope this makes sense?
  • 03-25-2013 04:09 PM In reply to

    Re: Update fields from drop down not working

    Can't seem to attach more than one file at a time!
  • 03-25-2013 04:55 PM In reply to

    Re: Update fields from drop down not working

    Yup - you can always put files in a zip and attach that as well.

    So - put a rule on Company - no condition - to set a field's value. The field you are going to set is the main data source field for the contact person.

    The XPath to get the right contact name should be:

    xdXDocument:GetDOM("Contacts")/CONTACTS/COMPANY/CONTACTPERSON[../@NAME =current()]

    You could also do this with the UI in IP - select the CONTACTPERSON field in the secondary data source, and then add a Filter (using the Filter button). The first dropdown for the filter would be the @NAME attribute on COMPANY. The middle would be is equal to and the last one, you'd select a field or group, go to the main data source, and select the main data source field bound to the drop down.

    Hilary Stoupa

  • 03-25-2013 05:12 PM In reply to

    Re: Update fields from drop down not working

    Thank you Hilary! That worked :)

    Yes, a zip file... Brain is too focused on Infopath right now.

    So, the ../@NAME is referencing the path to the parent node? I just want to get this clear in my head so I can to the other similar forms. Does it matter how the XML is formatted in terms of attributes or elements? I have seen a lot of examples using, what I call self containing tags like: < Player ID="10" FirstName="Chipper" LastName="Jones" No="10" Position="3B" / >

    Thanks for your time and assistance :)

  • 03-25-2013 05:35 PM In reply to

    Re: Update fields from drop down not working

     So ../@NAME is a relative XPath. We are at CONTACTPERSON - so ../ takes us back to COMPANY, and @NAME gets us the company name attribute - @NAME is an attribute on COMPANY. Here's a blog post of mine with some links to learning XPath resources. I think what you are calling self containing tags are attributes. In the sample above, Player is an element, ID, FirstName, etc - those are attributes.

    Hilary Stoupa

  • 03-25-2013 05:49 PM In reply to

    Re: Update fields from drop down not working

    Thanks Hilary :)

    I just tried using the same formula on a repeating section but it's not working. Is there another approach to a repeating section for this? Thanks again.

  • 03-26-2013 07:08 AM In reply to

    Re: Update fields from drop down not working

     It all depends on where you are using the formula. If you'd attach a template under the options tab, I'd be happy to help you with it.

    Hilary Stoupa

  • 03-26-2013 02:54 PM In reply to

    Re: Update fields from drop down not working

    Attached is the template with the xml data files. As you can see, there is a repeating table with individual courses and values that populate into other areas. What I want is to simply select a course group to show only courses within that group and for the duration to be updated in the CourseDuration field. Thanks for your help!!
  • 03-26-2013 03:06 PM In reply to

    Re: Update fields from drop down not working

     So - your Course dropdown uses CourseName for the value. Your rule for setting course duration is depending on @Name instead.

    You want:

    xdXDocument:GetDOM("Courses")/COURSES/COURSECODE/DURATION[../COURSENAME = current()]

    For the filter on Course Group, the expression looks like:

    ../COURSEGROUPNAME = current()/my:CourseGroup

     

     

    Hilary Stoupa

  • 03-26-2013 03:53 PM In reply to

    Re: Update fields from drop down not working

    Thanks again Hilary!

    I think I'm struggling a little getting used to the syntax. I know roughly how it should look but just not quite there.

    The Course duration is working well, thank you. I tried the CourseGroup filter but came across some syntax type errors - not a valid path to CourseGroup so I ended up using this: xdXDocument:GetDOM("Courses")/COURSES/COURSECODE/COURSEGROUPNAME = current()/../my:CourseGroup

    The /../my:CourseGroup seemed to do the trick but now the select a course returns a "false" and "true" value into the drop down...


  • 03-26-2013 04:02 PM In reply to

    Re: Update fields from drop down not working

     What are you trying to do there? Are you setting a rule to set Course Name? I just meant to use it as a filter for the selected row for the drop downs - should already be in place in the sample I attached to my reply? You are getting true or false because that is what the XPath you have pasted above evaluates to - either they are equal or they are not... :)

    Hilary Stoupa

  • 03-26-2013 04:26 PM In reply to

    Re: Update fields from drop down not working

    Ah, yes... oops. My bad. I was getting it mixed up where the filter should go and I didn't look at your example properly!
  • 03-26-2013 04:35 PM In reply to

    Re: Update fields from drop down not working

    Works perfectly now :) Thanks a bunch for your help!!
Page 1 of 2 (16 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.