I am attempting to update a list outside of my app web. When I find the list, I am finding my column, then casting that into a TaxonomyField. The purpose of casting is to be able to play with get_termGuid() which would then let me get to set_termGuid.
The following works just fine, but I'm not getting the results that I am expecting.
myField.get_typeDisplayName() gives me 'Managed Metadata'
but using taxFieldValue.get_termGuid() gives me "". So when I attempt to load taxFieldValue, I get
'Object doesn't support property or method 'get_$19_0''
Something seems off, what am I missing here? Most of the samples that I have seen out there are for getting the value of a specific list item. What I am trying to do is alter the Term Store Settings for a specific list column. Not seeing too much out there on that.
edit also, I was then looking at what the process is for creating a new list column using JavaScript and noticed that the only option for this type of column is addFieldAsXml. So that did not help out my situation any.
var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
var clientContext = new SP.ClientContext.get_current();
var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
siteUrl = hostweburl + '/' + url;
var hostcontext = new SP.AppContextSite(clientContext, siteUrl);
oWeb = hostcontext.get_web();
oList = oWeb.get_lists().getByTitle(title);
listFields = oList.get_fields();
myField = listFields.getByInternalNameOrTitle("ACKeyWord");
taxField = clientContext.castTo(myField, SP.Taxonomy.TaxonomyField);
taxFieldValue = taxField.getFieldValueAsTaxonomyFieldValue();
clientContext.load(oList);
clientContext.load(myField);
clientContext.load(taxField);
clientContext.executeQueryAsync(Function.createDelegate(this, onListFieldsSucceeded), Function.createDelegate(this, onListFieldsFailed));