DocBuilder Fails To Merge Documents With Specific Content Controls

DocumentBuilder version: 9.2.1.8
Installation method: Docker

Summary:

I have a business scenario to merge several DOCX files together programmatically. I came upon the following post Combining three documents into one and followed its suggestions in terms of how to combine documents in the example scripts. It worked perfectly and everything behaves as expected except for the following scenario:

  1. Create two DOCX files to combine.
  2. In the 2nd DOCX file, add a Combo Box or a Drop-down list Content Control:
  3. I then utilized the below script to combine the documents:
builderJS.SetTmpFolder(
  "DocBuilderTemp-dbb55704-f54e-4bb0-870a-1b20196d8fc0"
);

builderJS.OpenFile("Document_1_without_content_controls.docx", "");

const capturedDocument0 = Api.GetDocument();

GlobalVariable[
  "dbb55704-f54e-4bb0-870a-1b20196d8fc0"
] = capturedDocument0.ToJSON(true, true, true, true, true, true);

builderJS.CloseFile();

builderJS.OpenFile("Document_2_with_content_controls.docx", "");

const mainDoc = Api.GetDocument();

const appendedDocument0 = Api.FromJSON(
  GlobalVariable["dbb55704-f54e-4bb0-870a-1b20196d8fc0"]
);

mainDoc.MoveCursorToEnd();
mainDoc.InsertBlankPage();
mainDoc.InsertContent(appendedDocument0);

builderJS.SaveFile(
  "docx",
  "merged-a9772d6c-24a3-452a-902b-8bdd50f379aa.docx"
);

builderJS.CloseFile();

This fails with a code of -3 and I see the following logs:

nodeJS - stderr:TypeError: Cannot read property 'lastValue' of undefined

ExitCode (code=1;signal=null;error:-80)

I have confirmed virtually every other feature works with combining documents except for those two content controls where the error being thrown shows it comes from OnlyOffice.

Please let me know if you would like any further information or clarifications.

Best,

Zac

Hi @zac213,

Thanks for the details, we’ll dig into this and keep you in the loop.

1 Like

Hi @zac213,

We tried to reproduce this on our end , created two DOCX files with Combo Box and Drop-down List content controls and ran the same merge flow on Document Server 9.2.1 Docker. The merge went through without issues and the content controls were preserved.

We weren’t able to reproduce the error so far, so a couple of questions:

  1. Would you be able to test this on DocumentBuilder 9.3.1 to see if the issue persists there?
  2. If it does, could you share the DOCX files that trigger the crash? It’s possible there’s something specific about the content control setup in your files that we’re missing with our test documents.

A short screen recording showing the error would also help a lot if possible.

Thanks!

1 Like

Thanks for the quick response @Nurullo!

I have pulled down version 9.3.1 and can confirm the same issues appears. I have tried to attach the two documents to this thread but the portal gives me the following error:

”Sorry, new users can not upload attachments.”

Additionally, I can share a screen recording but it would be limited to just the docker logs as I cannot share interactions or internals about the app I am working on due to security/contractual obligations.

Is there a different portal or way to communicate with the team here that could make this conversation more private?

Best,

Zac

Hi @zac213,

Thanks for the update! We tested the same merge flow on both standalone DocBuilder and Document Server’s DocBuilder (9.3.1) and couldn’t reproduce the crash on our end.

This suggests the issue may be specific to how the content controls are structured in your particular DOCX files. Could you share the following via any third-party storage (Google Drive, Dropbox, etc.)?

  1. The two DOCX files
  2. The DocBuilder script you’re using
  3. A screen recording of the error (if possible)

Thanks!

1 Like

Hi @Nurullo,

Please see the below attached and let me know if you have any further questions.

1password public link containing script, doc1, doc2, and screenshot of error message

https://share.1password.com/s#GY5UJq5QPgaWIegp0S7mdqqvCqZOg__igkPcplXT11k

Full Script:

builderJS.SetTmpFolder(“DocBuilderTemp-e6bc33aa-7502-4483-ba70-0cd00a31e96b”);

builderJS.OpenFile("doc1.docx", “”);
const capturedDocument0 = Api.GetDocument();
GlobalVariable[“e6bc33aa-7502-4483-ba70-0cd00a31e96b-doc_0”] = capturedDocument0.ToJSON(true, true, true, true, true, true);
builderJS.CloseFile();

builderJS.OpenFile("doc2.docx", “”);
const mainDoc = Api.GetDocument();

const appendedDocument0 = Api.FromJSON(GlobalVariable[“e6bc33aa-7502-4483-ba70-0cd00a31e96b-doc_0”]);
mainDoc.MoveCursorToEnd();
mainDoc.InsertBlankPage();
mainDoc.InsertContent(appendedDocument0);

builderJS.SaveFile(“docx”, “merged-4aa15d73-e5cd-459a-81ed-82129b7b60da.docx”);
builderJS.CloseFile();

My response from the Document server v9.3.1

Document Builder merge API returned error code -3. {"exception":"[object] (RuntimeException(code: 0): Document Builder merge API returned error code -3.

Please Note The Following:

  • I have been testing further on v9.3.1 and I believe the Dropdown content-control actually works now during merging compared to v9.2

Hi @Nurullo,

Quick follow up to inform that the doc2.docx shared in the 1password link is the problematic document which contains a combo box form control which creates out failure.

Please reach out if you have any questions or additional information required. Happy to jump on a call or assist in any way possible to the team for a resolution.

Appreciate your time as always,

Zac

Hi @zac213,

We tested the merge script with your files on Document Server 9.3.1.2 and were unable to reproduce the error — the merge completed successfully and the Combo Box content control was preserved in the output.

Could you help us narrow this down with the following:

  1. The exact steps you’re using to trigger the merge (how you’re calling the DocBuilder API)
  2. A screen recording of the full reproduction — from creating/preparing the files through to the error

Thanks!

Hi @Nurullo,

Apologies for the late reply as I was OOO for the past week.

I can definitely give a full screen recording with my explanation of how this is happening however as mentioned earlier, I cannot reveal code or screenshots of the application I am working on publicly.

The company I work for does actually pay for a support license so maybe I am in the wrong portal or have access to a more private way that isn’t public for all users to see to communicate with you?

Please let me know how we can facilitate next steps privately so I can get you and the team the proper information needed to resolve this issue.

Best,

Zac Zajdel

Hi @zac213,

No worries at all, welcome back!

Since you have a commercial support license, I’d recommend reaching out to us via Zendesk (https://onlyofficesupport.zendesk.com/) to get a prompt reply and share the details privately. That way you can send us the screen recording, files, and any other information without any confidentiality concerns.

Thanks!

1 Like