Autopopulate logged in User's info

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
christopher.young
Posts: 8
Joined: Wed Oct 05, 2016

06 Oct 2016

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

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

07 Oct 2016

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

christopher.young
Posts: 8
Joined: Wed Oct 05, 2016

12 Oct 2016

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.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

13 Oct 2016

Hi,

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests