How to query an XML file by creating a rule in Infopath 2010. - InfoPath Dev
in

InfoPath Dev

How to query an XML file by creating a rule in Infopath 2010.

Last post 01-10-2013 06:52 AM by PSKumar. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 01-09-2013 10:32 AM

    How to query an XML file by creating a rule in Infopath 2010.

    Hi all,

    I have a data connection to retrieve data from an XML file.  My users type in their Userid into a field on Infopath form
    and the XML data connection should fetch their name and contact details from XML file based on Userid.

    Below is the structure of my XML file.

    - <Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    - <Row>
      <ID>12345</ID>
      <Fname>Test1</Fname>
      <Lname>Test2</Lname>
      <Email>[email protected]</Email>
      <Phone>123-456-7890</Phone>
      </Row>
    - <Row>
      <ID>54321</ID>
      <Fname>Test3</Fname>
      <Lname>Test4</Lname>
      <Email>[email protected]</Email>
      <Phone>123-456-7891</Phone>
      </Row>
    </Root>

    Now when I am trying to build a rule some thing like below, it always fetches 1st record(12345) details even though i change the
    user id on the form to 2nd record.(54321).

    Condition: Userid is not blank
    Rule type: Action
    Run these actions:

    Set a field's value : ID = . [ User id field]
    Query using a dataconnection : TestXML
    Set a field's value : Emp_FName = FName
    Set a field's value : Emp_LName = LName
    Set a field's value : Emp_Email = Email
    Set a field's value : Emp_Phone = Phone

    Earlier i have used similar method to read Active Directory using SOAP service (GetUserProfileByName) and it worked fine.
    Now when i am trying to do similar method to get the data from XML file, it is not working. Please advise.

    Thanks in advance.

  • 01-09-2013 04:33 PM In reply to

    Re: How to query an XML file by creating a rule in Infopath 2010.

    Hi - your XML data connection does not have query fields, so the first two actions in your rule aren't really doing anything.

    In the fields task pane, drag the secondary data source onto your form so you can see the data and run those two actions and you should see that they make no difference - when that XML data source loads, it will have all the data.

    So, instead, you need to be using filters.

    When you set Emp_FName to Fname, you need to add a filter to Fname, that ID in the Row is equal to the User Id field you are currently trying to use in the query.

    Hilary Stoupa

  • 01-10-2013 06:52 AM In reply to

    Re: How to query an XML file by creating a rule in Infopath 2010.

    Thanks Hilary. It worked.

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