Is it possible to pass the parameter in url to Infopath form?

Recently one of my clients had a strange requirement for me, as they wanted to pass parameters in URL to the Infopath form. I did it before with asp, but never with InfoPath form. So let’s see what can be done. When I started digging into it I’ve discovered that there were not too many documents that described how to pass parameters in url to Infopath form, and if they exit they old . There’s also a Microsoft site: How to: Use Query Parameters to Invoke Browser-Enabled InfoPath Forms, but it will not provide an exact solution of our problem. And that’s all.

For my first test I just created a simple InfoPath form with two text fields:

InfoPath form
InfoPath form

It’s not too complicated. Now I would like to pass in url a parameter to field 1. In fact, without writing a code, there’s only one solution. We have to use InfoPath Form Web Part, and then we pass parameters to it. So how to do it? Let’s create a simple SharePoint page and then place on it the InfoPath Form Web Part.

InfoPath Form Web Part
InfoPath Form Web Part

Now we need a place where we store our parameters. To do this, we will add Query String (URL) Filter to our page. We add Query String Parameter Name to our filter web part. In my case, I just used Field1. Press apply, so now we can set up a connection to our web part. To do this, we simply go to connections -> send filter values to -> InfoPath Form Web Part.

Query String (URL) Filter
Query String (URL) Filter

And here’s one tip. If you get an error message during connection configuration:

The consumer Web Part did not provide schema information

You have to update your form. You have to go in your InfoPath to Option -> Advanced form options -> Property Promotion, and there you have to add your column, which will accept the parameter “The fields listed below will be available as SharePoint Web Part connection parameters”. After that, you have to redeploy your form.

Web Part Connection Dialog
Web Part Connection Dialog

When SharePoint updates our form, we can go back to our page. Let’s go again to our Query String (URL) Filter web part. Now when we select our connection again the dialog should appear. I am going to select Field 1 as the consumer field name. We pressed the save page button, and now we can make a test. Now If I enter in the URL window of my browser following string:

http://intranet.wingtip.com/sites/Programowanie/SitePages/FormPage.aspx?Field1=Tomasz

It will open my page with the first field (field 1) filled with my name Tomasz. And as you saw, this solution is simple at fast to pass parameters in URL to Infopath form. Unfortunately, we will have one big problem with a solution. It’s not possible to provide in this way more than one parameter. And in some cases, it’s not acceptable. We can do I will show you in my next post.