Skip to main content

Posts

Showing posts from September, 2016

[Improved Post] Update SharePoint Metadata (Taxonomy) column with Angular JS

After earlier post on the same topic which is updating taxonomy (managed metadata) column with Angular and with JSOM. Thought of optimize the code with more readable and with JavaScript promises. There may be areas further to be improved, for now sample code as below;

[code language="javascript"]
(function () {
'use strict';

// define controller
var controllerId = "MMSDevCtrl";

angular
.module('app')
.controller(controllerId, ['$q', mmsDevController]);

// create controller
function mmsDevController($q) {

//global var
var vm = this;

//value definitions
var siteUrl = 'http://win2012/sites/MSSDevTest';
var listName = 'MyDocumentLibrary';
var fieldName = 'MMSDepartments'; //MMS Column one
var fieldName2 = 'MMSDevLanguages'; //MMS Column two
var itemIdUpdating = 1; // Item to be udated
var termLabel = 'IT'; //'';
var termLabel2 = 'Java'; //'';
//add metadata column to sharepoint
vm.sub…

Get | Resolve Term ID for Term Value in SharePoint Metadata Service

This may be generic function you can use when you play with managed metadata (taxonomy) columns or with Managed Managed Metadata Service.

Notes:


Used JSOM since no impletation in REST API to get done this task in SharePoint to date of post
Passing term set ID is must since there may may be many term values equivalent in the term store
For the example, I have retrieved the term set ID from the list field which glued with the managed metadata service.


Following code illustrate how to get term ID for term value provided.

[code language="javascript"]

// Resolve Term ID for the Term Value
function getTermIdForTermValue(siteUri, listName, fieldName, termValue) {
//Define
var deferred = $q.defer()
, termId;
var clientContext = new SP.ClientContext(siteUrl);
var list = clientContext.get_web().get_lists().getByTitle(listName);
//Tx field
var field = list.get_fields().getByInternalNameOrTitle(fieldName);
var txField = clientContext.castTo(field, SP.Taxonomy.TaxonomyField);
//load context
cl…

Update SharePoint Metadata (Taxonomy) column with Angular JS

Check following code which updates provided SharePoint list/ library item with Managed metadata column.

First it solves GUID from the Managed Metadata service then push that value and other column values to the SharePoint back end.

Before execute following code you need properly configured "Managed Metadata Service" and list configuration with MMS.

[gist]a7de5ea23c0a441f89e66bf119e2688f[/gist]

Click here above is not visible.

If this code helped, don't miss to give feedback and following!

Managed Metadata Column Value Add with Angular | JavaScript & JSOM | CSOM

Following would be high-level program flow;

SP Taxonomy need to be imported.

[code language="javascript"]

var scriptbase = _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/";
$.getScript(scriptbase + "SP.Taxonomy.js");
[/code]

Create custom list item with metadata column in SharePoint with JSOM and Angular JS.

[code language="javascript"]
// Adding item to SharePoint custom list with Managed Metadata column (MMS column) with JSOM
(function () {
'use strict';

// define controller
var controllerId = "mmsColumnUploadCtrl";

angular
.module('app')
.controller(controllerId, ['$scope', mmsColumnUploadCtrl]);

// create controller
function mmsColumnUploadCtrl($scope) {
//global var
var vm = this;

//add metadata column to sharepoint
vm.AddMetadataColumn = function () {
var scriptbase = _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/"…