1

I need to create a taxonomy column as a site column in a site collection programmatically with REST. I only have access to REST (via flow) , I have no development capabilities besides rest.

I can create a normal column (Text, number etc) very easily with /_api/Web/Fields/createfieldasxml but with a metadata column we need a type called 'Notes' which I get an error of not well formed JSON when I attempt this.

Has anyone achieved this using REST calls ?

2
  • anybody any know-how ??? Jan 16, 2020 at 13:43
  • Maybe post a copy of the headers and sample body you are using so someone can take a stab at it in their own environment?
    – willman
    Jan 20, 2020 at 17:24

1 Answer 1

0

Figured it out..

var ctx = SP.ClientContext.get_current();  
    var web = ctx.get_web();  
    var fields = web.get_fields();  
    field = fields.getByInternalNameOrTitle("SessionTopics");  
    txField = ctx.castTo(field, SP.Taxonomy.TaxonomyField);  
    txField.set_sspId(termStoreId);  
    txField.set_termSetId(termSetId);  
    //txField.update();  
    txField.updateAndPushChanges(true);  
    ctx.executeQueryAsync(function(){                         
    },function(sender,args){      
          console.log(args.get_message());    
    });  
} 

Grab your site column Cast it to a taxonomyfield update the termstoreID, termsetID (get these from taxonomy page in sharepoint) and then do the usual executequery. DONE!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.