2014-10-10

A sample JS to clear the taxonomy field value using the JS CSOM.

example:

var context = SP.ClientContext.get_current();
var list = context.get_web().get_lists().getByTitle("list title");
var listItem = list.getItemById(58);
var field = list.get_fields().getByInternalNameOrTitle("taxonomyfieldname");
var taxField = context.castTo(field, SP.Taxonomy.TaxonomyField);
listItem.parseAndSetFieldValue("taxonomyfieldname", "");
listItem.parseAndSetFieldValue("taxonomyfieldnameTaxHTField", "");
listItem.update();
context.load(listItem);
context.executeQueryAsync(function () {},function(){});

The above code clears the Taxonomy field value using the “listItem.parseAndSetFieldValue”. “taxField.setFieldValueByValue(listItem, new SP.Taxonomy.TaxonomyFieldValue())” returns the following error.

{
"SchemaVersion":"15.0.0.0","LibraryVersion":"16.0.3312.1203","ErrorInfo":{
"ErrorMessage":"creatingField","ErrorValue":null,"TraceCorrelationId":"a1dec09c-0053-1000-8d36-7798643084e4","ErrorCode":-1,"ErrorTypeName":"System.MemberAccessException"
},"TraceCorrelationId":"a1dec09c-0053-1000-8d36-7798643084e4"
}
]

 

About the author 

Balamurugan Kailasam