JSOM SharePoint Online Create Term with custom shared and local properties

The sp.Taxonomy.js can be used to create a term in the taxonomy store. I wanted to create Shared Custom properties on the term. However the JavaScript library on MSDN  mentions only  the method setLocalCustomProperty which creates or updates a local custom property.

The SetCustomProperty is mentioned in MSDN to use in CSOM managed code to create or update shared custom property on a term. There is a lack of documentation how to use the method in JSOM.  Following the convention of method name in JavaScript ,i.e. camelCase , I called the  method on a term object in JavaScript and it worked.

term.setCustomProperty("ClientId",1234);

The JSOM code below provides a UI to specify the term to create. To test the code, copy and paste the code into a JavaScript file, upload the JavaScript file into the site and reference the JavaScript file from a Content Editor WebPart.

CreateTerm

When the button “Create Term” is clicked, the term is created with the shared and local custom property.

TermWithCustomProperties

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s