Page 1 of 1

Autopopulate logged in User's info

Posted: 06 Oct 2016
by christopher.young
I am using the following Javascript to Autopopulate the User's information into the form

SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
ctx.load(web);
var user = web.get_currentUser();
user.retrieve();
ctx.executeQueryAsync(
function () {
fd.field('User_x0020_who_x0020_needs_x0020').value(user.get_loginName());
fd.field('User_x0027_s_x0020_Official_x002').value(user.get_email());
});
}), "SP.js");

I would like to inlcude other information such as the User's Work Phone and User Name, see image below from SharePoint

Re: Autopopulate logged in User's info

Posted: 07 Oct 2016
by Dmitry Kozlov
Hi,

You can obtain user's display name from the user object:

Code: Select all

user.get_title()
As for the phone, you should retrieve it from user's profile:

https://msdn.microsoft.com/en-us/librar ... 20104.aspx

Re: Autopopulate logged in User's info

Posted: 12 Oct 2016
by christopher.young
I have attempted to use the information in that link several times but not only have I been unsuccessful, when I attempt to merge the scripts the original script becomes inoperable.

Re: Autopopulate logged in User's info

Posted: 13 Oct 2016
by Dmitry Kozlov
Hi,

Our support team ca implement the script for you. Please, send the detailed requirements to support@spform.com and we will estimate them.