Is it possible to pass parameter in url to Infopath form?
Recently one of my clients had strange requirement to me, as they want to pass parameters in url to Infopath form. I done it before with asp, but never with InfoPath form. So let’s see what can can be done. When I start dig in it I’ve discovered that there’s no to many documents which described how pass parameter in url to Infopath form and if they exits they old . There’s also Microsoft site: How to: Use Query Parameters to Invoke Browser-Enabled InfoPath Forms, but it will not provide exact solution of our problem. And that’s all.
For my first test I just created simple InfoPath form with two text fields:
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 parameter to it. So how to do it? Let’s create simple SharePoint page and then place on it InfoPath Form Web Part.
No we need place where we store our parameter. To do this we will add Query String (URL) Filter to our page. We add Query String Parameter Name to out filter web part. In my case I just used Field1. Press apply, so now we can set up connection of our web part. To do this we simple going to connections -> send filter values to -> InfoPath Form Web Part.
And here’s one tip. If you get 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 be accept parameter to “The fields listed below will be available as SharePoint Web Part connection parameters”. After that you have redeploy your form.
When SharePoint update 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 again our connection the dialog should appear. I am going to select Field 1 as the consumer field name. We pressing save page button and now we can make a test. Now If I enter in the url window of my browser following string:
It will open my page with first field (field 1) filed with my name Tomasz. And as you saw this solution is simple at fast to pass parameter in url to Infopath form. Unfortunately we will have one big problem with solution. It’s not possible to provide in this way more than one parameter. And in some cases it’s not acceptable. What we can do I will show you in my next post.
I've detected an ad blocker...
This site relies on ad revenue to generate content.
Please consider disabling your ad blocker for my site. Thank you!