Form design, database query and update - InfoPath Dev
in

InfoPath Dev

Form design, database query and update

Last post 05-02-2007 08:42 AM by Clay Fox. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 05-01-2007 02:48 PM

    Form design, database query and update

    I am working on a travel profile form and have a question on how to do a 
    database retreival and an update in the same form.
    
    I have a web service that pre-populates name and email based on Active 
    Directory.  That event happens on form load.
    
    When email is populated, I would like that to trigger a query against a 
    profile database and return fields from a database. (e.g., field 1, field2, 
    etc)
    
    I set a rule on the email field to query the database and then set one of 
    the fields (field1) to the query value but it does not work.
    
    Eventually, the user will then be able to update those fields, if necessary, 
    and resubmit the record to the database with the updates.
    
    I have the WDSL working but I cannot get the form to automatically retrieve 
    the data from the database (SQL in my case).
    
    In one word - HELP!!!
    Thank you for your Help.

    Art
  • 05-01-2007 11:37 PM In reply to

    Re: Form design, database query and update

    I am not completely sure if you are using a webservice of a database data connection.  This is doable as a database connection; query records, update them and submit them back to the database, but you need to have a form based on a database.  The database must be your primary dataconnection.  To do this you have to begin the form as a database form and it will create query fields and datafields for your datasource. Then you can add in your AD connector and other secondary data connections.

    I list out how to do a simple test and get familiar here. http://www.infopathdev.com/forums/post/19467.aspx

    If you are using a webservice then you would need to set it up to do both query and submit, which I think takes two seperate services typically but I do not have as much experience in that area.

    You would need two steps, once you set the query value you need a second rule to actually query the data connection.

    Hope this helps

  • 05-02-2007 06:37 AM In reply to

    Re: Form design, database query and update

    I am using a web service only for the Active Directory data. 

     The form was designed from the beginning as a database connection.

    To add to the frustration, here is an update:

    I was able to get the issue to run on one field and one field only. I use email as the primary key. I set the field email via WSDL from AD and then search my database for matching email addresses.

    When I went to populate the field First Name, I set a rule on email to say set the value of First Name based on this data selection and filter:

    ../../dfs:queryFields/q:tblTravelProfile/@FirstName[../../../my:TravelerInfo/my:Email = ../../../dfs:dataFields/d:tblTravelProfile/@EMail]

    And the Field of First name gets populated correctly.

    When I add a second stop to the rule to set Last Name I used the exact same data selection:

     ../../dfs:queryFields/q:tblTravelProfile/@TravelFirstName[../../../my:TravelerInfo/my:Email = ../../../dfs:dataFields/d:tblTravelProfile/@EMail]

    And the field of last name will not populate. I even tried to set it up as a second rule rather than a second step in the same rule with no luck.

    HELP!!!

    Thank you for your Help.

    Art
  • 05-02-2007 07:44 AM In reply to

    Re: Form design, database query and update

    Hi oldradio99,

    It looks like you are on the right path, but I think you are getting some XPath errors.  The second XPath listed looks like it goes to @TravelFirstName, which does not seem correct since you are looking to populate the Last Name field.  Since you got First Name working, it should be very similar to get Last Name working.  I would step through the XPath very carefully and see if you can find the problem.

    Good luck!

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-02-2007 08:21 AM In reply to

    Re: Form design, database query and update

    How do you step through the XPath?

     I did show the incorrect example

    First Name was correct

    ../../dfs:queryFields/q:tblTravelProfile/@FirstName[../../../my:TravelerInfo/my:Email = ../../../dfs:dataFields/d:tblTravelProfile/@EMail]

    but last name is

     ../../dfs:queryFields/q:tblTravelProfile/@LastName[../../../my:TravelerInfo/my:Email = ../../../dfs:dataFields/d:tblTravelProfile/@EMail]

    And it still only works on first name but not last name or any other field on the form

    It seems to do the first field retreival but not any others.

    Thank you for your Help.

    Art
  • 05-02-2007 08:42 AM In reply to

    Re: Form design, database query and update

    My recomendation would be to go back to basics with this. Here is what I would do to troubleshoot this.

    I am assuming the your email field displays once it is selected, to verify it is correct.

    I would add another view to your form for this testing just to make the clean up easier later.  Then I would add a button temporarily to switch to this testing view.

    In the testing view I would add the field from the webservice. (email address)

    I would add the field from the queryfields that is your primary key to the view. (email address)

    Then I would add all of the datafields as a repeating table or section with controls below that.  You will maybe need a button to run your query of the main data connection if this is not done as a rule already.

    But then with this test view you should be able to see the whole data flow and audit exactly what is in your fields.  If you need to you can change the email address and requery to make sure everything is flowing properly. When you query your main data connection you should get only one data record and it should be complete.  This should be what you are displaying to your users to view or update and then submit back.

     Hope this helps.

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