I'm developing a Word Add-in (Word API + Office.js) where i am working with content controls, i am try to check whether control is blank
i am using the below code for this functionality
function callPromise() {
return new Promise(function (resolve, reject) {
var MadatoryFieldsList = ["Control1", "Control2", "Control3"];
$.each(MadatoryFieldsList, function (index, element) {
Word.run(function (context) {
var contentControls = context.document.contentControls.getByTag(element).getFirst();
contentControls.load('text');
return context.sync().then(function () {
var text = contentControls.text;
if (text == "") {
//document.getElementById('lblMandatory').innerText += element + " is Mandatory" + " ";
mandatoryflag = "False";
}
if (index === MadatoryFieldsList.length - 1) resolve();
})
});
});
});
}
this works fine when i create the content control manually from developer tab in word document ... but if i copy the same from different document or load it from database in the form of OOXML it is not able to fetch the controls.
please let me know if i am missing something