Autopopulate logged in User's info
-
- Posts: 8
- Joined: Wed Oct 05, 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
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
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
You can obtain user's display name from the user object:
As for the phone, you should retrieve it from user's profile:
https://msdn.microsoft.com/en-us/librar ... 20104.aspx
You can obtain user's display name from the user object:
Code: Select all
user.get_title()
https://msdn.microsoft.com/en-us/librar ... 20104.aspx
-
- Posts: 8
- Joined: Wed Oct 05, 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.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
Our support team ca implement the script for you. Please, send the detailed requirements to support@spform.com and we will estimate them.
Our support team ca implement the script for you. Please, send the detailed requirements to support@spform.com and we will estimate them.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 5 guests