8

I have apply JSLink to the custom list's new form. I want to query the user profile property which is Managed Metadata for entered user. I wrote below code which simply gives the string. But I want the full pair (term | term_id) from the user profile property.

function loadUserData(finalUserName) {   
    try {       
        var clientContext = new SP.ClientContext.get_current();

        var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

        var propertyName = "oiplbNativeDepartment"; 

        var targetUser = finalUserName;     
        userProfileProperty = peopleManager.getUserProfilePropertyFor(targetUser, propertyName)
        clientContext.executeQueryAsync(onSuccess, onFail);
    }
    catch(ex) {
        alert(ex.message);
    }
}

function onSuccess() {
    var messageText = "\"Native Department \" property is " + userProfileProperty.get_value();
    var value = userProfileProperty.get_value();
    document.getElementById('lblDepartmentValue').style.color='black';
    document.getElementById('lblDepartmentValue').innerHTML = value;
}

function onFail(sender, args) {
    alert("Error: " + args.get_message());
}

This code returns the string value which is only term without ID how do I get full pair of taxonomy?

  • Retrieving user profile properties always returns only the text value. The term id is never saved/accessible in the user profile. – Nsevens Apr 26 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.