pass value from form to form - InfoPath Dev
in

InfoPath Dev

Having trouble finding a blog or post that answers your question? Check out our Custom Search Page

pass value from form to form

Last post 10-26-2012 01:48 PM by Reymes M-R. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-29-2011 12:17 PM

    pass value from form to form

    I am new to infopath. Now I am developing an user interface which is connecting with an test database. what i wanna to implement is that when opening the main form, it will load data from the database automatically (i've already implement that), then i put a button for each record when i click the button there will be come out a new form which contain more detail information about this record depends on the ID.

    Now my question is that is it possible to transfer value from form to form which both are on local machine ( i didn't upload these form to sharepoint or other server)

    if it is possible, how to implement this? I have read a lot of articles, they all mention using XDocument. but when I typed Application in VSTA, there isn't XDocument option.

    Many thanks

      

    Filed under:
  • 08-01-2011 11:41 PM In reply to

    Re: pass value from form to form

    Hi YuwenLanxing,

    The input parameters should still work even if it's local. The challenge is the path. InfoPath will parse the command that is used to launch it and look for input parameters to the right of a question mark. For example: c:/temp/template.xsn?p1=v1&p2=v2. InfoPath will load p1 and p2 with values v1 and v2. To access these input parameters requires code, or you can inject the xsn with qRules and get the input parameters using a rule (no coding required).

    Good luck!

    Patrick Halstead
    InfoPath MVP
  • 08-02-2011 05:28 AM In reply to

    Re: pass value from form to form

    Hi Patrick thanks for your reply

    I have created the following code to try :

     Public Sub Select_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

          Dim recordForm As XmlForm = Application.XmlForms.NewFromFormTemplate("C:\Documents and Settings\speng\Desktop\Infopaht template\Record.xsn?UserID=1")

    End Sub

     there will be an error

    InfoPath cannot create a new, blank form.
    InfoPath cannot open the form. To fix this problem, contact your system administrator.
    
    Form template: C:\Documents and Settings\speng\Desktop\Infopaht template\Record.xsn?UserID=1
    The following form template for the form cannot be found: file:///C:\Documents%20and%20Settings\speng\Desktop\Infopaht%20template\Record.xsn%3fUserID=1

    but if i only open the new form without the parameter it works fine, do you have any suggestion

    Thank you so much

  • 08-02-2011 08:18 AM In reply to

    Re: pass value from form to form

    Actually, I think for forms not accessed via url, input parameters can only be passed as a command line switch (see this blog for more info).

    But, you know, you've got your recordForm object. So you can go ahead and set values in it.

     Dim recordForm As XmlForm = Application.XmlForms.NewFromFormTemplate("C:\Documents and Settings\speng\Desktop\Infopaht template\Record.xsn") 
     recordForm.MainDataSource.CreateNavigator().SelectSingleNode("my:myFields/my:UserID", NamespaceManager).SetValue("1")

    Obviously, I'm guessing at the XPath in bold above, but this should give you the general idea.
     

     

    Hilary Stoupa
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 08-02-2011 01:00 PM In reply to

    Re: pass value from form to form

    Thanks Hilary

    I tried your code, and created a textbox named "UserID" in the record template, but there is an error said "Object reference not set to an instance of an object"

    do you have any idea why

    Thanks

  • 08-03-2011 08:14 AM In reply to

    Re: pass value from form to form

    My guess would be that you haven't changed the XPath in the code to the XPath for the field you created in your form - but really, you should run your project in debug so you can see what's going on. Here's a blog post that describes how to do that.

    Hilary Stoupa
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 08-04-2011 12:16 PM In reply to

    Re: pass value from form to form

    Finially I made this out. At first for a test I didn't create any data connection for the record form which only has a textbox in  main datasource. Then I tried to connect this form with the database as well and using the following code

    Dim recordDatasource As DataSource = recordForm.DataSources("tbl_TemporaryLicence")

    recordDatasource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tbl_TemporaryLicence/@TempPermitID", NamespaceManager).SetValue("1")

    it works fine. maybe the problem is on the MainDataSource.

  • 10-26-2012 01:48 PM In reply to

    Re: pass value from form to form

    Hi there OPatrick

    I am having a similar problem with getting value of Query Strings param passed in the Url and I have tried a lot of stuff so far:

    1)

    HttpContext.Current.Request.QueryString("cou").ToString()

    After adding:
    Imports System.Web

    2)

    If eventParam.InputParameters.ContainsKey("cou") Then


                        eventParam.InputParameters.TryGetValue("cou", CountryQueryStringParam)

                        'Updating the field in the InfoPath form to be used at any time when the Country QueryString parameter is required
                        _CountryQueryStringParam.SetValue(CountryQueryStringParam)

    End if

    3.

     CountryQueryStringParam  = eventParam.InputParameters("cou")


    That’s everything that I have been trying so far. For all of them the Null value is being returned....It looks like the Url has not parameters at all, but is tis plenty of them: /EN/Pages/Product-Inquiry-Form.aspx?lang=e&src=Financing&code=Financing&s_products=LeadGen%3bFinancingInquiry_e%3b1%3b0&fromPage=NOTSET&cou=Albania

    .Any suggestions? I even tried by leaving only one parameters (lang) and the same outcome.

    Maybe I am miising some setting in the saherpoint site to allow having acces to that Url when dealing with InfoPath Forms?

    What are those qRules that you mentioned? How can be implemented?

    Thanks in advance for any help man.

    Regards,

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