Hello,
This post will show you, how you can access theuser profile information in SharePoint with javascript using client object model.
Thanks to Alexander for writing this post as it was much helpful.
Insert this code in a CEWP
1 | <script type= "text/javascript" src= "https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" ></script> |
2 | <script type= "text/javascript" src= "/test/EMSKJS/spjs-utility.js" ></script> |
3 | <script type= "text/javascript" > |
5 | var userInfoObj = getUserInfo_v2(_spUserId); |
6 | var name = userInfoObj.Title; |
7 | var email = userInfoObj.EMail; |
I have incorporated the new
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" ); |
Please note the extra “” as it must be escaped in javascript.
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
Download
Comments
Post a Comment