Setting a query field and running a query on form open - InfoPath Dev
in

InfoPath Dev

Setting a query field and running a query on form open

Last post 05-25-2007 12:14 PM by ssaral. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-24-2007 01:27 PM

    Setting a query field and running a query on form open

    Hi,

    I have a form in which you select a field value from an SQL db data connection, then click a button to launch another form and send that selected value to the new form. This value arrives in a query field in the new form that is connected to a similar data connection. The new form will query an SQL db based on this value when I press a Run Query button and display the results I want. My questions is how can I execute this queary when the new form opens without out having to press the run Query button?

    I'm using InfoPath 2003 SP2; below is the code I'm using to set the value in the new form:

    var sFormAValue = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:vw_ApplicationInformation/@AppInfoID").text;
    var xdFormB = Application.XDocuments.NewFromSolution("C:\\ARP_9.xsn"); 
    xdFormB.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s0="http://tempuri.org/" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:ns1="http://www.tempuri.org/dsFAF.xsd" xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns2="http://schemas.xmlsoap.org/wsdl/" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-02-21T16:45:01" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
    xdFormB.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/q:Glossary/@AppInfoID").text = sFormAValue;  

    When I tried to execute the query in the On Load Event code section it runs before the query value on the new form (target form) gets set, any ideas on how I can get this to work so it queries using the query value...thanks

       

  • 05-24-2007 07:04 PM In reply to

    Re: Setting a query field and running a query on form open

    I have successfully used rules to query data connections in the form open rules.  Typically I believe your field value should be there but I am not sure.  Can you put a query rule on a field? So that when the field is updated it would run the query? Can't test at the moment but I believe you might.
  • 05-25-2007 06:23 AM In reply to

    Re: Setting a query field and running a query on form open

    I used rules on form open and said query data source when the query field is present and query data source when the query field is not blank but both of those didn't work, but haven't tried to place the rule on the query field it self....that seems to work but it is rather inconsistent, might have to do with the data....I'll keep testing...thanks
  • 05-25-2007 10:46 AM In reply to

    Re: Setting a query field and running a query on form open

    Yah I tried it to and I think the rule on the field is the best solution. If you are having an issue with it executing more than once or early I would put some conditions on the rule to check the new value first or another field tht you can flag once it has been ran once.  I often use lots of expresion boxes to pop the field value in between each step to monitor what is happening to the value.

    Good Luck

  • 05-25-2007 12:14 PM In reply to

    Re: Setting a query field and running a query on form open

    Yep, I did place a condition on it...and seems to be working fine, the issue had to do with blank values...thanks...
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.