Cloud Computing Insider Awards 2022: Vote for ONLYOFFICE
Vote for ONLYOFFICE

Error in line with SearchAndReplace function

DocumentBuilder version: 4.4.1
Installation method: docbuilder.exe
OS: Windows 7 x64
I just copied this code from official api documentation (ONLYOFFICE Api Documentation - SearchAndReplace), put it in a .docbuilder script-file and… it doesn’t work.

builder.CreateFile(“docx”);
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText(“This is the first sample text. The serial number of this sample text was replaced here.”);
oDocument.SearchAndReplace({“searchString”: “first”, “replaceString”: “second”});
builder.SaveFile(“docx”,“c:\test.docx”);
builder.CloseFile();

Error is Uncaught TypeError: oDocument.SearchAndReplace is not a function (WHAT?)
What is that? And, of course, script doesn’t return any file.
2022-08-26_115611

Hello,
This is some really obsolete version of the document builder. Where have you downloaded it from?
Please install the current one (7.1.1) and use it.

7.1.1 works. Thanks.