0

Good day,

I have a question with getting user profile data from AD by JavaScript for SharePoint Display Form. I can get user Department by script:

<SharePoint:ScriptLink ID="ScriptLink2" name="SP.UserProfiles.js" runat="server"
    ondemand="false" localizable="false" loadafterui="true" />
…
var scriptbase = _spPageContextInfo.webAbsoluteUrl + "/_layouts/15/";
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
       $.getScript(scriptbase + "SP.UserProfiles.js", getUserProperties);
    });
…
function getUserProperties() {
        var context = new SP.ClientContext.get_current();
        var peopleManager = new SP.UserProfiles.PeopleManager(context);
        personProperties = peopleManager.getMyProperties();
        context.load(personProperties);
        context.executeQueryAsync(onRequestSuccess, onRequestFail);
    }

function onRequestSuccess() {
    console.log(personProperties.get_userProfileProperties()['Department']);
     persDepartment=personProperties.get_userProfileProperties()['Department'];
}
function onRequestFail(sender, args) {
    console.log('Error');
}

I would like to get user organization name (or Employer name) from AD. But persDepartment=personProperties.get_userProfileProperties()[Organization]; didn’t help.

Could you tell me how I can get Organization name?

Would be grateful for info.

1 Answer 1

0

You are getting the properties from the User Profile Service Application, not directly from Active Directory.

In order to retrieve a property you will first have to make sure that it is synchronized. Organization is not one of the standard properties that is synced I believe.

17
  • Thanks for reply. How can I make Organization to sync up?
    – Anonymous
    Apr 2, 2020 at 14:23
  • What SharePoint version is this? Apr 2, 2020 at 16:56
  • Sharepoint 2016
    – Anonymous
    Apr 3, 2020 at 7:37
  • 1
    Check the official documentation. There is a step-by-step guide. Point 16 and 17 tells you how to set up the sync once you have created the property. Apr 3, 2020 at 7:40
  • I im adding New Organization property. Point 16. In the Property Mapping for Synchronization section I see "No elements for displaying in this view". Point 17 - I can't specify the source data connection, attribute, and synchronization direction for the mapping because I don't see any attributes...
    – Anonymous
    Apr 6, 2020 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.