Monday, 14 July 2014

Retrieving SharePoint List read Managed Metadata Column using javascript

Retrieving SharePoint List Column Managed Metadata using javascript
1: var ctx = new SP.ClientContext();

   2: var targetList = ctx.get_web().get_lists().getByTitle('ListName');

   3: var queryItems;

   4:

   5: var query = new SP.CamlQuery();

   6: query.set_viewXml("<View><Query><Where><Contains><FieldRef Name='Id'/><Value Type='Text'>FilterValue</Value></Contains></Where></Query></View>");

   7:

   8: queryItems = targetList.getItems(query);

   9: ctx.load(mandatoryItems);

  10: ctx.executeQueryAsync(onGetSucceeded, onGetFailed);

  11:

  12: function onGetSucceeded()

  13: {

  14:     var listEnumerator = queryItems.getEnumerator();

  15:

  16:     while (listEnumerator.moveNext()) {

  17:         var keywords = listEnumerator.get_current().get_item("TileID")["Label"];

  18:         alert(childItem);

  19:     }

  20: }

  21: function onGetFailed(sender, args) {

  22:   alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());

  23: }