Unlock a ContentControl

Do you want to: Report a bug / Ask a how-to question

Up until now, if i wanted to unlock a ContentControl (i meant It can be modified & deleted) I used :

aContentControls[i].SetLock("unlock");

However, since version 9.0.0, it has stopped working — more precisely, since the “[bug] fix bug 74161” update. Unfortunately, I couldn’t find a description of this bug. :s

In practice :

Asc.plugin.callCommand(
    function() {
        var oDocument = Api.GetDocument();
        var aContentControls = oDocument.GetAllContentControls();
        for (var i = 0; i < aContentControls.length; i++) {
            console.debug(aContentControls[i].GetLock());
            aContentControls[i].SetLock("contentLocked");
            console.debug(aContentControls[i].GetLock());
            aContentControls[i].SetLock("unlocked");
            console.debug(aContentControls[i].GetLock());
        }
    }
);

and the console output is :

unlocked
contentLocked
contentLocked

There is anotherway to just unlock the the contentcontrol?

Thanks

Hello @humbol,
Thank you for reporting the issue. We are currently looking into it.

As a workaround, you can change the lock using the plugin method InsertAndReplaceContentControls:

It functions properly with 9.0. Sample command:

Asc.plugin.executeMethod("GetCurrentContentControl", null, (CC) => {
    console.log(CC);
    var CCprops = [{
        "Props": {
            "InternalId": CC,
            "Lock": 3
        }
    }];
    Asc.plugin.executeMethod("InsertAndReplaceContentControls", [CCprops])
    })

We are aiming to fix the SetLock(“unlocked”) method not working in DS 9.0.3.

@humbol
We have released Document Server 9.0.3 which fixes the unlock issue.