I have previously posted a solution for pulling user information from the built-in user information list in SharePoint (found in WSS 3.0, MOSS 2007 and SharePoint 2010 both foundation and server). This is NOT the user profile found in MOSS 2007 and in SharePoint 2010 server. You find the solution here
This solution is an updated version of the script – and should hopefully work better with sites on a managed path.
I have incorporated the new “getUserInfo_v2” in the file “spjs-utility.js”.
The parameter “_spUserId” is provided by SharePoint and represents the current user’s userID.
The function takes one argument which can be a userID or a login name (domainlogin or appname:user). If you use domainuser as a string like this:
var userInfoObj = getUserInfo_v2("contoso\alexander");
The variables “name” and “email” are examples, the full range of “out of the box fields” are:
ID, Name, Title, EMail, Department, JobTitle, Notes, Picture, IsSiteAdmin, Created, Author, Modified, Editor, SipAddress
You can download the file “spjs-utility.js” here. Ensure you pick the version dated 18.09.2011, or newer.
I tried using this and nothing shows up on the screen. I downloaded the above file and placed in a document library and then copied the code above and linked it to a CEWP. I made sure and changed the line 2 to reflect where my file is saved. I save everything but nothing shows in the CEWP box.
I tried also to using this … and nothing comes up. Must be change something other on the script to work?
Hi Rebecca and Steve,
This code does not display anything on the screen. Look at the code and see the variables “name” and “email”.
If you want a “feedback” – alert the variables.
Which other fields can i use? Tried het OOB Manager field but returned ‘undefined’, while i know this one is filled.
This script does not use the “user profile” from MOSS, it deals with the built in user list. The fields you can access are listed in the function “getUserInfo_v2” and involves: ‘ID’, ‘Name’, ‘Title’, ‘EMail’, ‘Department’, ‘JobTitle’, ‘Notes’, ‘Picture’, ‘IsSiteAdmin’, ‘Created’, ‘Author’, ‘Modified’, ‘Editor’, ‘SipAddress’.
You can however add extra fields add add those to the array.
Hi Alexander, this would be really useful for me but I cannot seem to download the utility j.s, he web page is unavailable, can you help please
It looks OK from here – if you have issues with https, try using http (edit the URL). Let me know if it still does not work.
This solution is good for getting information for users in userinfo list. How to get user profile information which are not added on the site?
I do not have access to a MOSS / SharePoint 2010 Server so i have not tested this function:
You must use the “spjs-utility.js” as it uses the function “spjs_wrapSoapRequest” from that library.
Please let me know if it works.
Hi, The solution you gave me works for current logged in user. What if I want information of different user? How do I pass user Id to the soap function?
Try adding the accountname (domain\user) between these tags
Note the double backslash if the account name is a string and not a variable.
This is not tested as I do not have access to SharePoint server.
I have the same needs of Sneha (retrieve domain user’s email), but the function gives me an “undefined” message.
Since the original function works very well, but retrieves only email of persons inside “All People” internal group, could you give me a proper solution to implement the original script?
Is there any chance that I could still download the js file? That website is unavailable . Or is there any other place where I could get the file from?
The link is updated.
are the three equal sign at line 123 of your function getUserInfo_v2 in spjs-utility.js intentional?
Yes, it is.
This works great, but is there a way to get the Work/Cell numbers of a user also by using this?
You must edit the function “getUserInfo_v2” found in the file “spjs-utility.js” and add the FieldInternalName of your “Work/Cell number field” to the array “arrOfFields”.
Hi, Alex very nice Post.I have tried and it works f9 for me.But I want to get the List of all the Colleague of current users. i have read your getUserInfo_v2 function but unable to edit as per my need.
Thanks an advance.
This works for me perfectly. Thank you!
how do we add new fields to the user list
You add fields here as for any other list, but you may need to be site collection administrator.
Thanks for the code..
This is working fine except for the field Mobile Phone..
How can we get mobilephone of a user ??
Update spjs-utility.js to v1.177 and then use this code:
“YourCustomPropterty” must be the FieldInternalName of the property from the use list.
yeah…!! i got mobile phone.. i added the field to the .js file.. 🙂
I added field “l” to get City of the user. But I got null as return value. I have admin rights to the site. Not sure what’s the issue. Rest of the field values are retrieved very well.
This script works with SharePoint 2013 with a very minor adjustment.
Replace _SPUserID with _spPageContextInfo.userId
Very useful, thank you.
The parameter “_spUserId” does not seem to be provided on the page. I think it has something to do with my current custom master page. Do you have any suggestions on how I can possibly “import” this field to the page?
Thank you very much.
Are you using SP2010 or 2013? – if so, you can use
We try to capture the current users SipAddress on a sharepoint page. We have several solutions that work in IE but no solution that also works in Safari.
Do you have a solution for us?
(We also tried the solution on this page)
Is this Safari for MAC, IPad or Windows? – any errors in the developer console (if there is such a thing in Safari)?
It is Safari on Windows (haven’t tried Mac)
We have turned on the console and got the following errors:
ReferenceError: Can’t find variable: jQuery
ReferenceError: Can’t find variable: getUserInfo_v2
It works fine in IE.
It seems the script on the server cannot be read.
So I included the script in the site collection and it works.
The question for me now is why does Safari not read from the server.
OK. Found it out.
Completely my mistake.
Thanks for the support.
I’m glad you figured it out. Please note that you must not refer the scripts from spjsfiles.com directly. This server is not fast enough to serve the scripts live.
I want to assign Te email I’d to a column in Te list how’s that possible
Add one line to the code example above:
PS: If you are using SP2013 you must change _spUserId for _spPageContextInfo.userId