window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [args], callback)


Defines the method that inserts a content control containing data. The data is specified by the js code for Document Builder, or by a link to the shared document.


This method should be used in the following way:

window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [obj]);

Where obj is a JSON array:

        "Props": {
            "Id": Number,
            "Tag": "{String}",
            "Lock": Number 
        "Script": "var oDocument = Api.GetDocument();var oParagraph = Api.CreateParagraph();oParagraph.AddText('Hello world!');oDocument.InsertContent([oParagraph]);" 

Each new element in the array will create a new content control.

[ {"Props": {...}, "Url": "http://"}, {"Props": {...}, "Url": "http://."}, {...}, {...}]

The Props key can have the following values:

  • "Id" (e.g. {"Id": 2} ) is a unique identifier of the content control. It can be used to search for a certain content control and make reference to it in the code.
  • "Tag" ( e.g. {"Tag": "String"} ) is a tag assigned to the content control. The same tag can be assigned to several content controls so that it is possible to make reference to them in the code.
  • "Lock" (e.g. {"Lock": 0} ) is a value which defines if it is possible to delete and/or edit the content control or not. The values can be as follows:
Numeric value Edit Delete
0 No Yes
1 No No
2 Yes No
3 Yes Yes

Besides the Props key, there must be a Key/Value pair containing the Url or Script key that defines the data that that the content control will contain. If the Url key is used, its value must be a link to the shared file. If the Script key is used, its value must be a script that will be executed to generate data within the content control.

Example 1
    "Url": ""
Example 2
"Script": "var oDocument = Api.GetDocument();
var oParagraph=Api.CreateParagraph();

The method returns the data which the created content control contains (in JSON format)

        "Tag": "Document",
        "Id": 0,
        "Lock": 0,
        "InternalId": "1_713"