I am creating an SharePoint hosted app. In that I have to use Managed MataData from my list. In this I am getting the Metadata from my list column to my Taxonomy control.
I have find some post but I am not able to get the all the meta data. Code I am using is as below.
function execOperation() {
try {
context = new SP.ClientContext(hostweburl);
var factory =
new SP.ProxyWebRequestExecutorFactory(
appweburl
);
context.set_webRequestExecutorFactory(factory);
appContextSite = new SP.AppContextSite(context, hostweburl);
web = appContextSite.get_web();
context.load(web);
//My List with Taxonomy column
taxonomyList = web.get_lists().getByTitle("Test");
context.executeQueryAsync(onSuccess, onFail);
}
catch (err) {
alert(err.message);
}
}
function onSuccess() {
try {
debugger;
//Getting the taxonomy filed from the list
taxonomyControl = taxonomyList.get_fields().getByInternalNameOrTitle("Name");
context.load(taxonomyControl);
taxField = context.castTo(taxonomyControl, SP.Taxonomy.TaxonomyField);
context.load(taxField);
context.executeQueryAsync(onSuccessTaxonomyValues, onFail);
}
catch (err) {
alert(err.message);
}
}
//This code is suppose to fill the taxonomy filed. But it is not working.
function onSuccessTaxonomyValues() {
debugger;
var webTaggingCtl = $get("ctl00_PlaceHolderMain_ctl01editableRegion");//On page taxonomy control.
var taxCtlObj = new SP.Taxonomy.ControlObject(webTaggingCtl);
taxCtlObj.enableControl(true);
taxCtlObj.setRawText(taxField);
taxCtlObj.retrieveTerms();
}
My actual question is How can I fill TaxonomyWebTaggingControl
control, which I placed on my page, with the above code?
Can any one help me to solve this?
Thank you in advance...!