Creating User Property Programmatically Using JSOM In SharePoint/ O365


In this article, we will see how to create a user property programmatically, using JavaScript Object Model (JSOM). Before going to the code first, we will see what the user property is and how to get into the Service.

The user properties and user profile properties provide information about SharePoint users, such as display name, E-mail, title, other business and personal information.

In client-side APIs, we can use two properties to access the user details.


  • SharePoint Server 2013
  • Visual Studio 2012 or higher version

To access the User Profile Service, we need to include the reference file given below in the ASPX page.

  1. <SharePoint:ScriptLink ID="ScriptLink1" name="SP.js" runat="server" ondemand="false" localizable="false" loadafterui="true" />  
  2. <SharePoint:ScriptLink ID="ScriptLink2" name="SP.UserProfiles.js" runat="server" ondemand="false" localizable="false" loadafterui="true" />   

The code is given below and the article explains how to get the user profile properties from the userproperties object and how it works.

This article demonstrates how to create and use a user property in SharePoint Online (O365).

A user profile is the collection of the user properties that describes about a single user. The property includes basic details, policies and settings. Most of the organizations get a headache  maintaining user profile properties in an efficient way but it helps the people to find the content that connects them with other people.

Based on the user profile properties, you can learn many things about the user and connect with them, using social features like blogs and discussions.

The admin from SharePoint Online can enhance the SharePoint capabilities by adding the user profile properties, defining user policies, and creating the audiences.

Here are the basic screenshots I have added to access the user profile Service.

Open your SharePoint Central Admin on the Server and click Application Management, followed by selecting user profile Service.

Afterwards, you will get a new screen. Click SharePoint link for redirecting to the screen given below.

The user profile has three important sections. I have explained about the sections here.

  1. People

    In this people section, Admin can manage all the user properties and profiles .They can provide the permissions for audience.

  2. Organization

    This section is for managing an organization's details.

  3. My Site Settings

    This is totally for MySite related topics.My Sites are essentially personal portals that give individual users the ability to have a one-to-many collaboration path with the enterprise.

Now, we will see how to manage User Properties.

Click the "Manage User Properties" link under the "People" heading. You will be redirected to the below screen.

The basic default properties are available under here and you can use this page to add, edit, organize, delete or map user profile properties. Profile properties can be mapped to Active Directory or LDAP compliant directory services. Profile properties can also be mapped to Application Entity Fields exposed by Business Data Connectivity.

Here, you can create a new user propery and new section.Those details can be explained in the next article.

Now, we will see how to create a User Profile property programmatically using JSOM.

Specify property settings for this property. The name will be used programmatically for the property by the user profile service, while the display name is the label used when the property is shown.

After the property is created, the only property setting you can change is the display name. Specify a description for this property, that will provides instructions or information to the users.

Source Code

  1. var personProperties;  
  2. SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');  
  4. function getUserProperties() {  
  5.     var targetUser = "SPDEV\\gwotham";  
  6.     var Context = new SP.ClientContext.get_current();  
  7.     var peopleManager = new SP.UserProfiles.PeopleManager(Context);  
  8.     personProperties = peopleManager.getPropertiesFor(targetUser);  
  9.     Context.load(personProperties);  
  10.     Context.executeQueryAsync(Success, Fail);  
  11. }  
  13. function Success() {  
  14.     var displayName = personProperties.get_displayName();  
  15.     var department = personProperties.get_userProfileProperties()['Department'];  
  16.     alert(displayName);  
  17.     alert(department);  
  18. }  
  20. function onRequestFail(sender, args) {  
  21.     alert(args.get_message());  
  22. }  


The above article will help you to understand how to access the SharePoint Online User Profile Property.

Thanks for reading my articles.