Wednesday 5 June 2013

InfoPath Data Connections

In this post We're going to create a InfoPath form that reads job titles from a SharePoint list and submits itself to a SharePoint Forms Library, but we are going to store our Data Connection in a SharePoint Data Connection Library. We have Three prerequisites for this:

What do I mean that our forms library is only going to be a place holder? in InfoPath to create a Submit to Library Data Connection you actually need to have this document library on your site. For now just make a Document Library through the SharePoint UI and call it FormLibrary, in a subsequent post I'll demonstrate how to deploy the Form we are making here via a WSP package.

Make Note of the forms URL, http://spm/FormLibrary
With the above three complete, open up InfoPath and create the following form.

With your form complete it's time to make your data connections, Go to the Data Connection Tab and click the Data Connections button.

This will bring up the Data Connections Window, it looks like this

What you're going to do is click the add button, the first thing we're going to do is specify that we want to retrieve data.

Next we are going to specify that we're going to retrieve our data from a SharePoint Library or list, in our case it'll be that Job Titles list we made previously.

Next select the site where the list you wish to pull data form resides.

Pick the columns you need in your form and the order you want them sorted. In our case we are going to need the Title Column and we should sort it in ascending order.

In the next window we can choose to store a copy of the data in our form, I leave this unchecked because I'll be using a web based form. If you utilize infopath filler then you might want to check this off... i guess...

Now give your data connection a unique name, I generally like to use camel case

When you click finish you'll be brought back to the data connection window, with your new data connection listed what we are going to do is select our getJobTitles Data connection and convert it into a Data connection file, at this point if you don't have a Data Connection Library this will not work.

Next you're going to specify the location of your Data connection library and append it with the file name you want the data connection to have. Hit OK and you're Job titles Connection file is created.

Now you should be back at your Data connection window, if you want you could open your data connection library in your browser to inspect the file you just created.
Next let's run through that entire process again, but this time let's build a data connection for the form submit. Back at the Data Connections window click the add button one more time.
Again you'll be asked whether you want to submit or receive data, this time pick submit.
next pick "To a document library on a SharePoint site"
Give your Data Connection a name
Click finish, you should go back to the Data Connections window, select your newly made data connection and convert it to a data connection file as well.
Just Like before specify your data connection library url and append it with the file name you want your data connection to have.

again go to your Data Connection library in your browser to see the newly added data connection file.
Now save both data connection files to your hard drive, we are going to move them into our projects, also publish your form to the same network location, we’re also going to deploy that using our visual studio solution.
And that’s it you've created your form and two Data Connections, One to Submit your form to a library and one to Fetch job types from a SharePoint list.