0

When i tried to update "Manager" field in Sharepoint online with API Rest, throws an exception. I am a global admin of the tenant.

"{"odata.error":{"code":"-1, Microsoft.Office.Server.UserProfiles.PropertyNotEditableException","message":{"lang":"es-ES","value":"Propiedad no editable: esta propiedad solo puede modificarla un administrador."}}}

This is the code:

 function updateManager() {
     var selectedUser = $("#usuarios").find(":selected")[0].value;
  var newManager = $("#newManagers").find(":selected")[0].value;



    var requestHeaders = {
        'X-RequestDigest': $("#__REQUESTDIGEST").val(),
        "accept": "application/json; odata=nometadata",
        "content-type": "application/json;odata=nometadata"
    };

    var userData = {
        'accountName': "i:0#.f|membership|" + selectedUser ,
        'propertyName': 'Manager', //can also be used to set custom single value profile properties
        'propertyValue': "i:0#.f|membership|" + newManager
    }

    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/SetSingleValueProfileProperty",
        type: "POST",
        headers: requestHeaders,
        data: JSON.stringify(userData),
        success: function (data) {
            console.log(data)

            var successHtml = '<div class="ms-MessageBar ms-MessageBar--success"><div class="ms-MessageBar-content"><div class="ms-MessageBar-icon"><i class="ms-Icon ms-Icon--checkboxCheck ms-Icon--circle"></i>'+
                                '</div><div class="ms-MessageBar-text">El Responsable se ha modificado con Exito!'+
                                '</div></div></div>';
            $("#userManager").html(successHtml);
            document.getElementsByClassName("ms-u-slideUpOut10").show();

        },
        error: function (jqxr, errorCode, errorThrown) {
            console.log(jqxr.responseText);
        }
    });
}

any idea please?

1

Go to admin center > sharepoint > user profiles. ( need sharepoint admin rights)

Click on Manage user properties

Find & Edit the manager property.

Change the setting as below. Wait for couple of mins.

enter image description here

Run your code again, it should work.

2
  • Thanks Gautam, but I dont like user can change ther own "Manager" property. – Ikatz Feb 28 '17 at 10:57
  • 1
    It's an either or unfortunately, you either allow this so it can be edited or it gets updated via Azure AD Connect synchronization only. – Eric Alexander Feb 28 '17 at 14:29

Your Answer

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

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