I have been working on a solution for a client that involves a couple of different InfoPath forms. One of the forms we want users to be able to open using a link and have it pre-populate with specific data. We can easily do this by using the parameter options when we publish the form to InfoPath. For this first blog post I just want to walk through the process of publishing the form with parameters. In a future blog post I will put together more of the solution pieces.
We are starting with a very simple form example. It contains a drop down where the user can select a color. I know, horrible example, but I just want to show the concept in this post
So we start out with our InfoPath form:
We publish to a form library on our site:
Now this is the screen in the wizard that matters to us:
The first section allows us to take fields from our form and push them to a SharePoint library. This is the same feature that has been available in the past. The second section is where we identify what fields we want to use for parameters for web parts. We can select that the parameters are input, output or input / output. Since we have the new form web part this feature is what we are going to use to build out web part pages with connected web parts.
Here is what our configuration screen looks like for my example:
Once you finish the publishing wizard then we can use the form on a page. For my example I am going to add two web parts to my page:
- Query String Filter
- Form Web Part
This will allow me to pass a parameter from the query string and use that as a value for my form. Here are my two web parts on the page:
The first thing I do is configure my form web part to display my custom form. In my example we just need to connect with the form library and select to display the specific view that I want.
Here is a screenshot of my configuration-
Now we just need to configure the query filter web part and connect it to the form web part. For the query filter web part to work it is expecting that the URL that links to the page will have an added parameter. In our case, we will be using a parameter called “Color”. Parameters are included in the URL with the format of “?Parameter=Value”.
In the web part configuration we just need to name the query (name will be used later for connection) and the parameter.
Next we just need to configure the web part connection. From the Query web part select the options to connect web parts from the web part menu.
Select the parameter in the Form that connects to the query string:
Now when you load the page and the user has a parameter within their URL, the form will be pre-populated to match the query.
In a future blog post I hope to cover a more complex example where we use an SPD workflow to generate the URL for the user so that the form is prepopulated for them based on the actions in a previous workflow. For now, I just wanted to cover the concept so we could reference it in a future post.