Auto-Populating Fields from Active Directory Fields
Hi SPForms Community!
I'm trying to auto-populate information from AD when a user selects a specific field.
When the user selects an item from the "Employee" People Picker, there are a few subsequent drop down boxes that should be populated:
a. Department
b. Job Title
c. Supervisor
I have found a few articles on the Forum that helps point to referencing this but further elaboration would be much appreciated.
Links I referenced:
viewtopic.php?f=1&t=1997&p=7881&hilit=A ... tory#p7881
viewtopic.php?f=1&t=434&p=1739&hilit=Ac ... tory#p1739
https://zimmergren.net/sharepoints-hidd ... tion-list/
I'm trying to auto-populate information from AD when a user selects a specific field.
When the user selects an item from the "Employee" People Picker, there are a few subsequent drop down boxes that should be populated:
a. Department
b. Job Title
c. Supervisor
I have found a few articles on the Forum that helps point to referencing this but further elaboration would be much appreciated.
Links I referenced:
viewtopic.php?f=1&t=1997&p=7881&hilit=A ... tory#p7881
viewtopic.php?f=1&t=434&p=1739&hilit=Ac ... tory#p1739
https://zimmergren.net/sharepoints-hidd ... tion-list/
Hello axt3641,
You can try the following code to retrieve user profile properties:
Where PropertyName is the name of the property, e.g. Department.
You can try the following code to retrieve user profile properties:
Code: Select all
SP.SOD.executeOrDelayUntilScriptLoaded(function(){
var scriptbase = _spPageContextInfo.webAbsoluteUrl + "/_layouts/15/";
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
$.getScript(scriptbase + "SP.UserProfiles.js", getUserProperties);
});
function getUserProperties() {
var targetUser = fd.field('Employee').value().Key;
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
personProperties = peopleManager.getPropertiesFor(targetUser);
alert(personProperties);
clientContext.load(personProperties);
clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
}
function onRequestSuccess() {
fd.field('FieldName').value((personProperties.get_userProfileProperties()['PropertyName']));
}
function onRequestFail(sender, args) {
console.log('Error');
}
}, "sp.js");
-
- Information
-
Who is online
Users browsing this forum: No registered users and 11 guests