Forms are everywhere. You would be hard pressed to find some sort of business process that doesn't involve the use of some form. Developing InfoPath forms can be done to make many processes electronic. Combine the power of InfoPath 2007 with SharePoint's InfoPath Services and you can really make some dynamic forms with workflows to automate complex business processes.
So, lets say you have designed an InfoPath form that is a request form. What do your users want you to do? Make the process faster! What is the easiest way to do that? Make as many fields auto-populate as possible. What InfoPath combined with SharePoint's User Profile Service does is allow you to populate user information with no code! This means that the end user doesn't have to enter their information when you already have it populated in Active Directory (AD).
To get the current user's information:
1. Open InfoPath 2007 and click Design a Form Template.
2. You can choose to design from a blank form, one you have already created, or customize a sample.
3. Click Tools>Data Connections, then click Add to add a new connection.
4. Ensure "Create a new connection to:" is selected and select the radio button next to "receive data" then click Next.
5. Web Service should be selected, that is what the User Profile Service is, then click Next.
6. Enter the following address for the web service: http://<your site here>/_vti_bin/UserProfileService.asmx then click Next.
7. A list of options for the data will be shown, scroll down and select GetUserProfileByName, click Next.
8. Do not change the parameters, click Next.
9. Do not check "Store a copy of the data in the form template", click Next.
10. Ensure "Automatically retrieve data when the form is opened" is checked. You can change the name of the connection if you desire. Then click Finish.
Now you have this data connection, but that is a lot of work, right? Let's make it easier for future forms. We can take this connection and convert it to a universal data connection and store it in a library within SharePoint to be used in other forms. Leave your Data Connections open, in your SharePoint site, create a Universal Data Connection Library. Site Actions>Create (or View All Site Content>Create), select Data Connection Library from the Libraries list, title it and set the navigation and versioning as preferred.
Now, back to InfoPath.
11. Ensure that the data connection you created is highlighted and click Convert.
12. Enter the URL of the library (or browse to it) and the filename of the connection. Make it meaningful to you and don't forget the .udcx file extension.
13. For most power users who may create forms, select the "Relative to site collection (recommended)" option, click OK. This means that any forms posted within that site collection can utilize this single data connection that has already been created.
You will need to go to the Data Connection Library and approve the connection before publishing your form. For future forms, you only need to create a new data connection, select "Search for connections on a Microsoft Office SharePoint Server". Select your site (or manage sites to add your site to the drop-down), expand the data connection library, select your connection and then continue through setting up the data connection.
Alright, now we have this data connection, how do we use it to auto-populate fields in the form?
1. Double-click on any text box (or add one to your form) to adjust the properties.
2. In the default value field, click on the function button.
3. Click "Insert Field or Group".
4. Select your data connection from the drop-down menu, click OK.
5. Expand the "data fields" and all sub-folders until you can select the "Value" field, then click "Filter Data".
6. Click "Add" to create a new filter.
7. Where the "Value" field is defaulted, click the drop-down and select "Select a field or group..."
8. Select the "Name" field under "Property Values", click OK.
9. In the third field, click the drop-down and select "Type Text".
10. Type the property from the user profile that you wish to enter in the field, then click OK until you are back at your form.
11. Repeat this process on all of the fields that you want to auto-populate.
Below are some of the more common properties that you can filter on to populate your form. This is not an exhaustive list, but you can look at the Profile Properties that are defined within your Shared Services Provider for more.
So, now you can have a request form that auto-populates data about the current logged in user who is completing the form. All without writing a single line of code! Stay tuned, tomorrow I will show you how you can take this data connection and combine it with another InfoPath control to auto-populate data for users other than the currently logged in user.