Skip to content
Amal Hashim
All posts
Article

SharePoint Online - Update UserProfile Properties

Update custom profile properties as a non-admin user in SharePoint Online by calling the old user profile web service through SPServices.

1 min read#JavaScript#SharePoint#jQuery

A requirement came up where end users needed to update custom user profile properties. These users are not administrators, so they cannot use the standard admin page. I looked at several options.

Options that did not work

  • Server side code: the target is SharePoint Online, so this is ruled out.
  • CSOM: the user profile properties are read-only.
  • JSOM: the properties are available for reading only.
  • REST API: there is no method to update user profile properties.

The user profile web service

The older user profile web service is still available, and it has a method called ModifyUserPropertyByAccountName. To check whether it really works, I used SPServices to keep the call simple:

js
<script type="text/javascript">
function Update() {
    var propertyData = "<PropertyData>" +
        "<IsPrivacyChanged>false</IsPrivacyChanged>" +
        "<IsValueChanged>true</IsValueChanged>" +
        "<Name>PROPERTYNAME</Name>" +
        "<Privacy>NotSet</Privacy>" +
        "<Values><ValueData><Value xsi:type=\"xsd:string\">PROPERTYVALUE</Value></ValueData></Values>" +
        "</PropertyData>";
    $().SPServices({
        operation: "ModifyUserPropertyByAccountName",
        async: false,
        webURL: "https://site.com",
        accountName: ACCOUNTNAME,
        newData: propertyData,
        completefunc: function (xData, Status) {
            alert(Status);
        }
    });
}
</script>

Replace PROPERTYNAME, PROPERTYVALUE and ACCOUNTNAME with your own values, and set webURL to your site.