tag:blogger.com,1999:blog-4455058894110083658.post6908418845225070411..comments2024-02-26T22:59:25.161+00:00Comments on Vardhaman Deshpande: SharePoint Online: Write User Profile Properties with REST APIVardhaman Deshpandehttp://www.blogger.com/profile/17919845281919756108noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-4455058894110083658.post-29328191178949623442017-03-06T10:39:58.629+00:002017-03-06T10:39:58.629+00:00Hi Imanol,
I am afraid you cannot set the propert...Hi Imanol,<br /><br />I am afraid you cannot set the property from JSOM unless you set the property as editable by the user.<br /><br />One workaround could be that you set the property as editable by the user but hide it from the delve profile by unchecking "Show on the Edit Details page". But bear in mind this will only hide the property but the user will still be able to update it through other ways such as code etc.<br /><br />Thanks Vardhaman Deshpandehttps://www.blogger.com/profile/17919845281919756108noreply@blogger.comtag:blogger.com,1999:blog-4455058894110083658.post-91085905759945044002017-02-28T11:15:38.169+00:002017-02-28T11:15:38.169+00:00Hi,
Congrats for the post! It´s very usefull.
...Hi, <br /><br />Congrats for the post! It´s very usefull. <br /><br />When I tried to update "Manager" field, throws an exception. I am a global admin of the tenant and I dont like to put the property editable for the user.<br /><br />"{"odata.error":{"code":"-1, Microsoft.Office.Server.UserProfiles.PropertyNotEditableException","message":{"lang":"es-ES","value":"Propiedad no editable: esta propiedad solo puede modificarla un administrador."}}}<br /><br />This is the code:<br /><br /><br /><br />function updateManager() {<br /> var selectedUser = $("#usuarios").find(":selected")[0].value;<br /> var newManager = $("#newManagers").find(":selected")[0].value;<br /><br /><br /><br /> var requestHeaders = {<br /> 'X-RequestDigest': $("#__REQUESTDIGEST").val(),<br /> "accept": "application/json; odata=nometadata",<br /> "content-type": "application/json;odata=nometadata"<br /> };<br /><br /> var userData = {<br /> 'accountName': "i:0#.f|membership|" + selectedUser ,<br /> 'propertyName': 'Manager', //can also be used to set custom single value profile properties<br /> 'propertyValue': "i:0#.f|membership|" + newManager<br /> }<br /><br /> $.ajax({<br /> url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/SetSingleValueProfileProperty",<br /> type: "POST",<br /> headers: requestHeaders,<br /> data: JSON.stringify(userData),<br /> success: function (data) {<br /> console.log(data)<br /><br /> },<br /> error: function (jqxr, errorCode, errorThrown) {<br /> console.log(jqxr.responseText);<br /> }<br /> });<br />}<br /><br /><br />any idea? how can I update manager propety?<br /><br />Thanks in advance.Imanolhttps://www.blogger.com/profile/01862614626904710381noreply@blogger.com