To debug ONLYOFFICE macros, follow the instructions below.
Use the debugger command in your script:
debugger; var oDocument = Api.GetDocument(); var oParagraph = oDocument.GetElement(0); oParagraph.AddText("Hello world!");
To run your script in debug mode:
Open the developer console by pressing the F12 button.
Use the instruction for debugging in ONLYOFFICE Desktop Editors.
Press the Run button to run your script.
The debugger command works as a breakpoint and pauses the execution at the script point where this command is inserted.
If you just need to display the specific values in the browser developer console, you can use the console.log() method. Pass a value you want to check or just a message string as an argument of this method and open the developer console by pressing the F12 button to see the result:
console.log(123); var oDocument = Api.GetDocument(); var oParagraph = oDocument.GetElement(0); oParagraph.AddText("Hello world!");