Get Started
More information

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


Defines the method that allows inserting the 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", [arrDocuments]);
Parameter Description Type Example
arrDocuments An array of properties and contents of the content control. Each object from this array can have the following values:
  • Props - the content control properties,
    type: object;
  • Script - a script that will be executed to generate the data within the content control (can be replaced with the Url parameter),
    type: string,
    example: "{script}";
  • Url - a link to the shared file (can be replaced with the Script parameter),
    type: string,
    example: "".
array of objects

The Props object 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": "{tag}"} ) 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.
  • InternalId (e.g. {"InternalId": 1_713} ) is a unique internal identifier of the content control.
  • 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

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

        "Tag": "Document",
        "Id": 0,
        "Lock": 0,
        "InternalId": "1_713"
Example of changing the existed content control
var arrDocuments = [{
    "Props": {
        "InternalId": "2_803"
    "Script": "var oParagraph = Api.CreateParagraph();oParagraph.AddText('New text');Api.GetDocument().InsertContent([oParagraph]);"
window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [arrDocuments]);
Example of adding a new content control
var arrDocuments = [{
    "Props": {
        "Id": 100,
        "Tag": "CC_Tag",
        "Lock": 3
    "Script": "var oParagraph = Api.CreateParagraph();oParagraph.AddText('Hello world!');Api.GetDocument().InsertContent([oParagraph]);"
window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [arrDocuments]);