Nintex Form - working with managed metadata fields


This is a post I wrote late last year, and applies to the Managed Metadata Fields in Nintex Forms via some "JavaScript middle-tier magic". 



My conversations with the Nintex Form team back then was that at some point they might stop using the SharePoint Managed Metadata Fields and switch to their own control (similar to what they do with the people picker).  Then the following JavaScript code around Managed Metadata fields would stop working.



Nintex has a JavaScript wrapper API (NF.PeoplePickerAPI) around their People Picker Control.

Create something similar that allows me to wrap a Managed Metadata Field.




(function (SPG, $, undefined) {

    var ctor = function (elem) {
        this.$elem = $(elem);

        var $taxonomyEditor = this.$elem.find(".ms-taxonomy");
        if ($taxonomyEditor.length) {
            this.controlObject = new Microsoft.SharePoint.Taxonomy.ControlObject($taxonomyEditor.get(0));

    ctor.prototype = {

        replaceTerm: function(label, termGuid) {
            var self = this;
            if (self.controlObject == undefined) return;

            var term = new Microsoft.SharePoint.Taxonomy.Term(label + "|" + termGuid);

        clear: function() {
            var self = this;

        setRawText: function (text) {
            var self = this;
            if (self.controlObject == undefined) return;


    SPG.ManagedMetadataApi = ctor;
})(window.SPG = window.SPG || {}, NWF$);




  • List: My List
  • Field: MMField


    using "normal" GET REST request doesn't bring back ManagedMetaDataFields, this is a workaround.
    because GetItems is a method on the List, this needs to be a POST operation.

var url = _spPageContextInfo.webAbsoluteUrl +
    "/_api/Web/Lists/getByTitle('My List')/GetItems([email protected])" +
    "[email protected]={'ViewXml':'<View><Query><Where><Eq><FieldRef Name=\"ID\"/><Value Type=\"Integer\">" + siteID +  

var promise = NWF$.ajax({
    type: "POST",
    url: url,
    headers: {
        "accept": "application/json;odata=verbose",
        "X-RequestDigest": NWF$("#__REQUESTDIGEST").val()
    contentType: "application/json;odata=verbose",
    dataType: "json",
    cache: false,
    processData: true

promise.done(function (data) {

    var row = data.d.results[0];

    // similar syntax as NF.PeoplePickerApi
    var $mmField = new SPG.ManagedMetadataApi("#" + fieldMMField);
    if (row.MMField) {
        $mmField.replaceTerm(row.MMField.Label, row.MMField.TermGuid);