SHARE
TWEET

Untitled

a guest Jun 15th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var webUrl = _spPageContextInfo.webServerRelativeUrl;
  2.  var listTitle = "mylist";
  3.  var taxFieldName = "myColumn";
  4.  var termLabel ="termm label";
  5.  var termId = "a92b78b5-3505-45d5-abdd-b28e0b5385c5";
  6.  
  7.  var context = new SP.ClientContext(webUrl);
  8.  var list = context.get_web().get_lists().getByTitle(listTitle);            
  9.  var item = list.getItemById(301);
  10.  
  11.  //In case of multi-valued Managed Metadata field, the format of value is:
  12.  //-1;#<termLabel1>|<termId1>;-1;#<termLabel2>|<termId2>;...-1;#<termLabelN>|<termIdN>
  13.  
  14.  var termValue = "-1" + ";#" + termLabel + "|" + termId;
  15.  
  16.  item.set_item(taxFieldName, termValue);
  17.  item.update();
  18.  
  19.  context.load(item);
  20.  context.executeQueryAsync(
  21.         function () {
  22.             console.log('Item has been updated: ' + item.get_id());
  23.         },
  24.         function (sender, args) {
  25.              console.log(args.get_message());
  26.         });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top