Pass parameters into browser based infopath 2007 form - InfoPath Dev
in

InfoPath Dev

Pass parameters into browser based infopath 2007 form

Last post 07-16-2009 02:12 AM by Patrick Halstead. 13 replies.
Page 1 of 1 (14 items)
Sort Posts: Previous Next
  • 07-14-2009 01:20 PM

    Pass parameters into browser based infopath 2007 form

    Hello i have a browser enabled infopath 2007 form loaded on my Moss 2007 server. I am trying to pass a parameter to the form so when a user opens the form a field is automatically populated from the URL.

    I used VB code  "Public Sub FormEvents_Loading(ByVal sender As Object, ByVal e As LoadingEventArgs)

                                     Dim doctitleValue As String = e.InputParameters("doctitle")

                             End Sub"

     

    And my URL uses the parameter: "doctitle"

    http://sharepoint/Site/_layouts/FormServer.aspx?XsnLocation=http://sharepoint/FormServerTemplates/MyForm3.xsn&OpenIn=browser&SaveLocation=http://sharepoint/Site/Forms&Source=http://sharepoint/Site/Forms/Forms/AllItems.aspx&doctitle=Myname

    But when I open the form, there is nothing in the field. Any idea's one what could be causing this to remain blank?

  • 07-14-2009 11:26 PM In reply to

    Re: Pass parameters into browser based infopath 2007 form

    Hi MSanders79 and welcome!

    We have at least 3 blogs on this and there are probably 10 threads. Have you tried searching? If you don't find something, send me e-mail. There's tons of stuff here and on the http://blogs.msdn.com/infopath site. Search is your friend.

    Patrick Halstead
    Project Manager at Qdabra
  • 07-15-2009 01:52 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

    Yes sir, I've been all over the different posts. I wonder if mine could be a debug issue.

    I just created a brand new form with just 1 field in it called biz.

    I added my vb code

    Public Sub FormEvents_Loading(ByVal sender As Object, ByVal e As LoadingEventArgs)

                Dim biz As String = e.InputParameters("biz")

            End Sub
    then run from command line:

    infopath.exe "c:\biz.xsn" /InputParameters "biz=web"

    And my form still shows up blank. I'm really lost. :(

  • 07-15-2009 08:14 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

    Hi--

    It looks like you are passing in the input parameter....but not doing anything with it. Do you want to set a form field's value to your string variable biz?

    Like this:

    Dim field As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:fieldIWantToFill")
    field.SetValue(biz)

    Hilary Stoupa

  • 07-15-2009 08:34 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

     Yes, I am wanting to set a form field's value.

    Do I just add this code below, my code? Just changing the "fieldIWantToFill" to my field name (biz)?

     

  • 07-15-2009 09:52 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

    I forgot the namespace manager, so more like:

    Dim field As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:biz", NamespaceManager)
    field.SetValue(biz)

    The stuff in bold needs to be the exact xpath to your field. If you right click the field in the data source task pane and select Copy XPath, it will be on your clipboard and you can just paste it in.

    Hilary Stoupa

  • 07-15-2009 10:03 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

     Hilary thanks for the response.

    I followed those steps and still when I use the command line to send the parameters to the form it comes back empty in the field.  Is there something directly on the field I need to do? I copied and pasted the XPath as you explained.

     

    This is my Entire Form Code:

    Imports Microsoft.Office.InfoPath
    Imports System
    Imports System.Windows.Forms
    Imports System.Xml
    Imports System.Xml.XPath
    Imports mshtml


    Namespace bizform
        Public Class FormCode
            Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
                AddHandler EventManager.FormEvents.Loading, AddressOf FormEvents_Loading
            End Sub

            Public Sub FormEvents_Loading(ByVal sender As Object, ByVal e As LoadingEventArgs)

                Dim biz As String = e.InputParameters("biz")

                Dim field As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:biz", NamespaceManager)
                field.SetValue(biz)

            End Sub
        End Class
    End Namespace

  • 07-15-2009 10:07 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

    You can give variable 'biz' a temporary value and preview your form to be sure the value is being set by your code. So instead of:

    Dim biz As String = e.InputParameters("biz")

    You could say:

    Dim biz As String = "test"

    And preview your form. Does your field get populated?

    Hilary Stoupa

  • 07-15-2009 10:15 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

     When I try that method I get this error below.

    System.Security.SecurityException
    Request failed.
       at Microsoft.Office.InfoPath.MsxmlNavigator.IsValidNode(MsxmlNode test)
       at Microsoft.Office.InfoPath.MsxmlNavigator.MoveToFirstChild()
       at MS.Internal.Xml.XPath.XPathChildIterator.MoveNext()
       at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
       at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
       at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()
       at System.Xml.XPath.XPathNavigator.SelectSingleNode(XPathExpression expression)
       at System.Xml.XPath.XPathNavigator.SelectSingleNode(String xpath, IXmlNamespaceResolver resolver)
       at bizform.FormCode.FormEvents_Loading(Object sender, LoadingEventArgs e)
       at Microsoft.Office.InfoPath.Internal.FormEventsHost.OnLoad(DocReturnEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnLoad(DocReturnEvent pEvent)
     

  • 07-15-2009 10:40 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

     Figure out the error code. I had my form set at domain trust. I set it to Full Trust and the error went away. And the Form Field did get populated with the test text.

  • 07-15-2009 10:45 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

    Just so you know, you shouldn't have to be at full trust to run this code. Here's a thread with more info.

    Hilary Stoupa

  • 07-15-2009 10:47 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

     Once I saw the form was getting populated I put back in my old code to get the parameter, but it was still filling the form with "test" text. So I found how to clear the infopath cache with the command line: infopath.exe /cache clearall

    Then I tried the command line pass parameter again, and it worked!

    Looks like I was cached the old form over and over again? 

    I think I am good to go. Just need to play with it, and add additional parameters to pass! 

    Thanks so much for the assistance!

  • 07-15-2009 06:36 PM In reply to

    Re: Pass parameters into browser based infopath 2007 form

     I'm also running .net 3.5. That's actually the thread I ran across and turned on full trust. I'm guessing this will be a problem when I deploy this form onto another server?

  • 07-16-2009 02:12 AM In reply to

    Re: Pass parameters into browser based infopath 2007 form

    Well, Full Trust is a bad practice because it increases cost to your users - you either have to sign the form and the users have to accept a digital certificate for it (or server admin has to configure Certificate Authority), or you need to create a local install of your form. Both ways are extra cost. Like Hilary said you shouldn't have to do this. Uninstall .NET 3.5 if you can and try that.

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (14 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.