Skip Ribbon Commands
Skip to main content

Laura Rogers @WonderLaura

:

Quick Launch

Laura Rogers @WonderLaura > Posts > User Information within InfoPath Forms
Hi everyone,
My blog now has a new URL!
You can now find me at http://www.wonderlaura.com
April 11
User Information within InfoPath Forms

There is a quick and easy way that information about the logged in user can be obtained from within an InfoPath form. You may have read my blog and other blogs before, with the user profile service web service instructions. In this post, I'm not going to be using the user profile service. This means that what I'm about to show you can be utilized with any version of SharePoint, whether you have a user profile service (enterprise) or not. This can be done with SharePoint 2010 Foundation, SharePoint 2010 enterprise and standard, and also WSS 3.0 and MOSS.

The User Information List is a list that exists at the site collection level, and contains a list of every user who has actually visited the SharePoint site. If they are a new user, they will not show in this list until they've actually visited a site in that site collection.

With that said, here are some instructions for getting some information about users, more specifically, the currently logged in user.

  1. Open up your InfoPath form, click on the Data tab, and click the Data Connections button.
  2. Click the Add… button.
  3. Choose Receive Data, and click Next.
  4. Choose SharePoint List or Library, and click Next.

  5. Paste the URL of your SharePoint site, click Next. (No need for any "default.aspx" at the end, or any other .aspx)
  6. Scroll down towards the bottom of the list of lists and libraries, and select User Information List. Click Next.
    (note that even though the user information list physically exists at the site collection level, you will still see this list on every sub-site also)

  7. Put check boxes next to the following fields, especially User_name. Click Next.

  8. Do not check the box to store a copy of the data. Click Next.
  9. This is very important. UNCHECK the box to automatically retrieve the data. Click Finish.

  10. On the Data Connections screen, click Close.
  11. Still on the Data tab in InfoPath, click the Form Load button, which will bring up the rules pane on the right side of the screen.
  12. Click the New button to create a new Action rule.
  13. Click the Add button and choose Set a Field's Value. On the Rule Details screen, click the button next to Field.
  14. In the Fields drop-down box, choose User Information List, expand the queryFields, and select User name.
    (be sure that you're selecting from the query fields, not the data fields.) Click OK.

  15. Back on the Rule Details screen, click the function (fx) button next to the Value box.
  16. Click the Insert Function button, and choose the userName function. Click OK two times.

  17. This is what your rule looks like. Click OK.

  18. Back over in the rules pane on the right, click the Add button, and choose Query for Data.
  19. Choose the User Information List and click OK.

  20. Now, each time the form is opened, the current user's information will automatically be queried, and that one record will be retrieved. There are many ways that this information can be used within your form. The data exists in the data fields of the user information list. In the Fields pane on the right side of the screen, choose the User Information List from the drop-down box.
  21. Select the folder directly under dataFields, the one with the blue icon called d:SharePointListItem_RW. Drag it onto an empty area of your form, and when you let go, choose Repeating Section with Controls.
    I'm really just having you put all this on the form so that you can see exactly what's being returned.

  22. Go ahead and publish the form, and open a new form. You'll see all of the data about you will be displayed, something like this:

  23. One more little trick. Go back to InfoPath Designer. Delete the "Picture" field. Add a Picture control to the form (not a picture button, just a picture), and choose As a link. Click OK.
  24. You will be prompted to bind to a field. Select the Picture field under the User Information List data fields. Click OK.

  25. Filling out the form again, now there's me:

     

    You can see how this data could potentially be used in many ways in your form. You can set some field defaults the first time the form is filled out, you could display the currently logged in user's picture… You can even use formatting rules to show, hide, or disable certain fields depending on who the current user is or what department they're in. I don't usually drop the fields on the form like I showed you, that was for demonstration purposes. I usually just refer to that data via rules, etc. Keep in mind that the user information list does not have the 60 or so fields that the user profile service contains, but it is very useful nonetheless. There are many other blog posts out there that show how to tap into the user profile service using the web service in InfoPath, it's just that if all you need is one of these basic fields, you might not need to deal with all of the complexity that it entails.

    Here are some other posts by me and others regarding user information in InfoPath:

 

Comments

Richard

A novel approach when the User Profile Service is not an option...

As always, another useful piece of InfoPath know how locked away in the armoury!

 on 4/12/2012 3:21 AM

Billy

Thanks Laura! This article is great!
 on 4/12/2012 9:35 AM

Melonie

Great approach, Laura!
 on 4/12/2012 10:38 AM

Clayton Cobb

Laura, there are a few major concerns with the UIL:
- It does not get updated when profile data changes in AD nor in the SharePoint Profile Database.  Data only gets added once, and it stays there in a separate table of the Content Database named UserInfo
- Likewise, every site collection has a different UIL, so one person's data may be different in each site collection depending on when they were added, and the lists themselves won't contain the same people
- It does not contain all users.  Users only get added to this list when explicitly reference in a Person/Group field like when adding permissions or assigning a task.  Most people will not show up in the UIL usually.

If the UIL would stay in sync with the identity provider and if it contained all people, then it would be great for this, especially for cases without UPS/UPA.  You can consider a custom solution to keep it updated with all users, but then that would need to run for all site collections and would make the UserInfo table quite large.
 on 4/12/2012 6:12 PM

Vikram Mulik(viks9884@yahoo.co.in)

Laura as you hve told user information list physically exists at the site collection level, but we have to first create one custom list naming user information List right and after that when we open blank infopath form we will select data connection and follow the steps which you have done above.
 on 4/18/2012 1:50 AM

Billie Jo

Laura this looks great, my head is spinning with some potential uses for it. 

I am currently using your steps from the "Step by Step InfoPath and SharePoint" book in Chapter 9 to connect to the user profile service.  I am using a people picker to gather the name and then gathering the email of that person.  It's working great when a single user is in the people picker.  If I allow multiple people to be selected however I only return the first in the field. I tried changing my email field that captures the data to a repeating field but that didn't yield any difference.  Any thoughts on how to pull back multiple emails for the multiple names entered in my people picker? 

Any thoughts are greatly appreciated, your speaches, books and blog posts have saved my butt more times than I can count. :)
 on 4/21/2012 6:08 PM

Vikram Mulik (viks9884@yahoo.co.in)

Hey Laura we get the information of the user which is login that's rite, but the information is gain itself by that user. If i am the admin of that site and i want to have information of user like how its show above displaying ur photo how will i get it . OR i have my own customer service desk site and i want my client or visitor to see my staff information in Infopath how will i achieve that.
 on 4/27/2012 8:01 AM

Laura

Clayton,
There's a timer job that updates the user information lists so that they stay accurate when the user profile service does exist.  This solution is mostly for people who don't have the luxury of the UPS.  I also already mentioned that people don't exist in the list until they've actually visited the SharePoint site.

Vikram,
No, I've never had to create a custom list before performing these steps, it just always shows there no matter what site or subsite you're on.

Billie Jo,
I can't think of how you'd do that except to have 2 different fields and multiple text fields to put their email addresses in.  Tricky.

Vikram,
At step 17 when you set a query field, you can set any of the query fields to anything.  Be creative.  If you set the Query field for Department to IT, then run the query, then what you'll get is a big list of everyone in the IT department.  Many examples.  Just if you have 1,000's of people in there I just don't recommend ever querying the whole list without a specific query.
lauraNo presence information on 5/3/2012 10:35 PM

arthra

Laura,

Is this possible to get SharePoint group for currently logged in user. I need to hide some of the fields for some group of users. now i am getting this data from one SharePoint list. That list contains login name and group name. Now i need to get the same from share point group. Is there any web services available for this... Please guide me... Thanks
 on 5/4/2012 6:38 AM

James

Hi Laura,

I’m using the information on chapter 9 of your book “Step-by-Step Using Microsoft InfoPath 2010 with Microsoft SharePoint 2010” to create forms that provide our users with a pre-populated form. 

We want users to open up a form and see that their first and last names are already included, along with their profile picture and email address.  We only want users to submit their own forms, so we are not using the People Picker option. 

Everything works perfectly except for the very last part.  When a user submits a form, the form is delivered to a SharePoint library.  The people in charge of processing the submitted forms are opening them up and finding that the form is populated with their own information, not with the information of the user who submitted the form. 

I’m sure I’m missing a simple step somewhere… can you please let me know how to setup the form so that the pre-populated information of the user who filled it out is what shows up when the completed form is opened by a different user? 

Thank you,

James 

P.S.  By the way, the book is an excellent resource!  I hope you get around to publishing a second one, with additional topics and features! 
 on 5/24/2012 10:56 AM

James

Hi Laura, 

Just wanted to follow-up on my question from yesterday (regarding the problem of the form being opened up by the people who process it, and finding that the pre-populated data on the form shows data on the people who are processing it, instead of data on the people who originally filled it out). 

The solution I found is this: 

Within the "Populate User Information" Form Load Rule, I set the Condition as follows: 

Attendee is blank

That took care of the issue I was having.  When the form is reviewed, it now opens up with the pre-populated information of the user that originally filled it out. 

I hope this is helpful to others. 

James 
 on 5/25/2012 7:46 AM

Laura

Arthra,
Sorry I haven't been able to find a good reliable no-code way to accomplish that.

James,
Cool, I'm glad you figured out the logic for that as a form load rule.  ;-)
lauraNo presence information on 6/13/2012 10:35 PM

Tina

Laura,
Thank you so much! I am one of the cases that is unable to get my ups web services working correctly.  This is a great workaround for me.
 on 7/2/2012 4:13 PM

Andrew

Could you use this for a SharePoint list as the first lookup?

I've user in a list and I'd like to generate many of their userprofile fields based on the username in the first column.
 on 7/12/2012 4:27 AM

Laura

Andrew,
Yes, absolutely you can do it that way.
lauraNo presence information on 7/17/2012 5:19 PM
​I have disabled any new comments on this, because my blog has moved to a new site.  Please go here: http://www.wonderlaura.com
RSS FeedFacebookYouTube
 

 Our Books for End Users