I noticed that with VBO you can call the method getSingleNode
to get a specific node object, is it possible to do something similar with office js?
Also, I have a radio button value in my Word metadata, I managed to access its customxmlnode
object, then I used setTextsync
method to change its value from true
to false
, but the new value I get for my radio button metadata is empty. Other text type metadata could be edited correctly though.
Could anyone give some suggestions?
function EditCTF() {
//$("#fields").css({ display: "" });
Word.run(function(context) {
context.document.properties.title = $("#Title").val();
Office.context.document.customXmlParts.getByNamespaceAsync(
"http://schemas.microsoft.com/office/2006/metadata/properties",
function(asyncResult) {
if (asyncResult.value.length > 0) {
var xmlPart = asyncResult.value[0];
xmlPart.getNodesAsync("*/*", function(nodeResults) {
console.log(nodeResults.value.length);
for (i = 0; i < nodeResults.value.length; i++) {
var node = nodeResults.value[i];
node.getTextAsync({ asyncContext: "StateNormal" }, function(result) {
console.log(result);
console.log(result.value);
});
console.log("NewValue");
if (node.baseName == "Address") {
node.setTextAsync(
$("#Address").val(),
{
asyncContext: "StateNormal"
},
function(newresult) {}
);
}
if (node.baseName == "MainContactPerson") {
node.setTextAsync(
$("#Main Contact Person").val(),
{
asyncContext: "StateNormal"
},
function(newresult) {}
);
}
if (node.baseName == "GDPR") {
node.setTextAsync(
"true",
{
asyncContext: "StateNormal"
},
function(newresult) {
console.log(newresult);
console.log(newresult.value);
}
);
}
}
});
}
}
);
return context.sync().then(function() {});
});
}