Passing parameters to a IP form from another IP form - InfoPath Dev
in

InfoPath Dev

Passing parameters to a IP form from another IP form

Last post 11-13-2009 04:57 AM by NashParrot. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 10-17-2008 03:20 PM

    • BigMo
    • Not Ranked
    • Joined on 10-15-2008
    • Posts 10

    Passing parameters to a IP form from another IP form

    I have a Infopath for with 3 cascading drop downs.  And the dropdowns are filled by a web service, depending on the selection from the above. This works perfect. Now when the user don't see the item listed in the dropdown, i have to give the user an ability to add new items --> open a new IP form --> submit that to DB -- refresh the main form back, so that it would have the newly added item.  I have no issues in adding items in the first drop down, lets say DDL1, since it is independent of the other.  But when i need to add items in the next dropdown (DDL2), i need to pass the value selected in DDL1 to the new form --> submit to DB --> refresh the main with the item selected in DDL1 & the DDL2 items.  What will be the best way to do it? Any help would be appreciated.

  • 10-17-2008 04:05 PM In reply to

    Re: Passing parameters to a IP form from another IP form

    I'm trying to think if there is a way to do this without code, and I can't think of one. At the very least, you'd need code in the Loading Event for Form B (the form opened from the main form) if you are passing in input parameters (http://formlibrary/template.xsn?foo=1&bar=2). And then you'd need to create the address of the form to open using a field from Form A. At that rate, the least complex solution might be to use the NewFromFormTemplate Method. MSDN has more information on that here. Here is also a C# code sample that may help you (an MSDN example that I've expanded slightly). Please note that this sample has no error handling and is written using the InfoPath 2007 Object Model.

                // Create an in-memory XML document.
                XmlDocument newDoc = new XmlDocument();
     
                //Get the value of the field that contains the data you want to pass to the new document
                XPathNavigator source = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Data", NamespaceManager);
     
                //Load xml into the in memory XML document. Don't forget to get the correct namespace for the form you want to load
                newDoc.LoadXml(
                   "<?xml version=\"1.0\" encoding=\"utf-8\" ?><my:myFields xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-07-21T15:40:24\"><my:field1>" + source.Value + "</my:field1></my:myFields>");
     
                // Create an XPathNavigator for the XML file.
                XPathNavigator newDocNav = newDoc.CreateNavigator();
     
                // Call NewFromFormTemplate to open new form and load XML.
                XmlForm newDocument =
                   this.Application.XmlForms.NewFromFormTemplate(
                   @"C:\SupportingForm.xsn", newDocNav);
    Hilary Stoupa

  • 10-22-2008 08:11 AM In reply to

    • BigMo
    • Not Ranked
    • Joined on 10-15-2008
    • Posts 10

    Re: Passing parameters to a IP form from another IP form

    I have a browser enabled IP form and I have referenced the namespace Microsoft.office.Infopath in the VSTA code.  Even then it is not recognizing the Application.xmlforms at all; giving me "xmlforms is not a member of "Microsoft.office.infopath.application" error.   Is this something specific to non browser enabled forms? If so whats the equivallent of that in a browser enabled form? or How can we achieve the above functionality in the browser forms?  I would appreciate your help.

  • 10-22-2008 08:38 AM In reply to

    Re: Passing parameters to a IP form from another IP form

    Wow -- sorry, I didn't realize this wasn't available for browser forms.

    I guess you will have to use input parameters instead. This means you'll have to have code in the Loading event of the form you wish to open and then figure out a way to pass in those parameters in the URL you open the form with.... One way would be to have a data field that holds the URL and populate the field when the value you need for the parameter changes, using the concat function to create the URL with the correct data in the parameters.

    Here is a blog entry from the IP team on the Loading event code you'll need, and here is a blog entry of mine on the the upper case 'gotcha' for those parameters.

    Hilary Stoupa

  • 11-13-2009 04:57 AM In reply to

    Re: Passing parameters to a IP form from another IP form

    I have a stupid follow up question to BigMo's

     All the examples I have seen has the "NewFromFormTemplate" reference to a xsn file on your c drive...

    this.Application.XmlForms.NewFromFormTemplate(

                   @"C:\SupportingForm.xsn", newDocNav);
     
    If I'm using another form library, and the xsn file is on the library itself.  (i.e.: http://myURL.com/MySharePointSite/Form2Library/Forms/template.xsn)...
    So, would the code look like this:
     this.Application.XmlForms.NewFromFormTemplate(
                   @"http://myURL.com/MySharePointSite/Form2Library/Forms/template.xsn", newDocNav);
     It doesn't seem to work when I try it this way, so I'm not sure if I'm doing something wrong.
    Thanks!
    NashParrot
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.