I'm trying to delete a content control in Word and I'm going through these docs: https://dev.office.com/reference/add-ins/word/contentcontrol
This is my code:
let mycc = context.document.contentControls.getByTag('mycc');
if (mycc) {
context.load(mycc, 'text');
context.sync().then(() => {
mycc.items[0].delete(true);
context.sync().then(() => { ... })
})
}
No error is thrown and the code inside the inner most sync works (inserting another content control).
What am I doing wrong?
EDIT: Found the issue. The content control was indeed being deleted, but I wanted to delete the content, as well. Instead of passing true
to delete
, I should have passed false
.