The Merge Document action allows you to merge multiple Microsoft Word or PDF files into one file, as well as convert Word files to PDF. This action takes the existing documents in an attached file field and combines them into one output file using your desired configuration settings. Merge Document actions are only compatible with .docx files from Microsoft Word 2010 or later, older .doc files are not supported. Other file types in the file field, such as image files or .xlsx files, are ignored when this action runs.

Merge Document actions work in a variety of situations where you want to create a single document from multiple attached files. For example, you might want to create a single file that includes a contract and all of its amendments. In this case, you could merge the original contract file in a local field with the files in a field from a related table that contains the contract's amendments. In another scenario, maybe you have a project with several tasks, and each task contains supporting documents. You could merge all of the supporting documents from the tasks into a single file in the project.

If you plan to convert from Word to PDF when you merge documents, you must have the Microsoft Word API enabled in your knowledgebase. For more information, see Microsoft Word Services Integration

Create a Merge Document Action

You can access the Actions wizard in several ways, but the easiest way is to select Setup [Table] from the table where you want to create the action.

  1. From the top nav bar, expand the table's drop-down and select Setup [Table].
  2. Select the Actions tab in the Table wizard.
  3. Click Create Merge Document Action. The Merge Document action wizard opens.
  4. On the General tab, give the action a name and description.

    Once your action is saved, the system automatically adds an M: before your given title to distinguish it as a Merge Document action.

  5. Click the Data Source Tab.

Data Source Tab

On the Data Source tab, you choose the fields holding the files that will be merged. You also select where the merged document is stored.

  1. Select the source field that contains the files. The source field can be a local file field, a linked file field from another table, or a file field in a related table.\
  2. If the source field is a field from a related table, you can choose a saved search to filter the records that the action operates on.
  3. For any of the options, you can also choose up to three additional fields that hold other files to be merged. If you choose additional fields, you must also select the order in which the original source field is merged. 

    The file you identify as First is also used for the headers and footers in the final output. If you want to merge the headers and footers across documents instead, create a Choice global variable named user_hdr_ftr_first_doc_4_merge and set it to No.


  4. Choose whether to open the document in the browser window or save it in another file field. If you save the document, you can append the file to the field or overwrite existing files.
  5. Create a default name for the merged file, using at least one variable so that the name is unique. Do not include the file extension, and use a space to separate any field variables from regular text.
  6. Click the Options tab.

Options Tab

Use the Options tab to configure various settings for the merged document.

  1. Select whether to output the merged file as PDF or Word (.docx) format. If you choose Word, the Merge or Convert First section is hidden, which allows you to manage Word to PDF conversion.
  2. Select the page size for the final output. If the source documents don't always use this page size, you can select the option to automatically scale the source documents if necessary.
  3. Decide how to manage page breaks in places where two documents are merged. The "Start each document on a new page" option inserts a page break when a new document is merged. The "Concatenate documents without inserting any page breaks" option merges documents seamlessly without any page breaks. The latter option only works when you merge Word files, either into another Word document or a PDF.
  4. If the output format is PDF, choose whether to include or ignore Word files during the merge. If Word files are included, choose whether consecutive Word files are merged and then converted to PDF, or whether Word files are converted to PDF and then merged. If you convert Word files to PDF and then merge them, they retain their original styles. If you merge consecutive Word files before converting to PDF, the pages of the merged document are numbered consecutively based on the first page number, and the first file's style definitions are used on all subsequent pages.

    If you merge a mixture of Word and PDF documents, consecutive Word documents may be merged with one style and then interrupted by PDF files, and any Word files that come after the PDF files take the style of the first Word file immediately following the last PDF file.

  5. If the output format is PDF, choose whether Word to PDF conversion should use MS Word services on the current server or a remote server. Word to PDF conversion requires the Microsoft Word API to work. For more information on how to configure this functionality in your knowledgebase, see Microsoft Word Services Integration.

  6. Click Finish.

Use Case

In an Incident record, imagine you want to create a single PDF from a group of several Word documents that provide supporting material. In the final merged document, you want consecutive page numbers and a consistent style.

Remember, before you get started, you need to enable the Microsoft Word API in your knowledgebase. See Microsoft Word Services Integration for more information.

Create the Fields

Before creating the Merge Document action, create the additional fields that the action will use.

  1. In the Incidents table, create a File with Versioning field that will contain the newly merged document.
  2. Name the field Final Supporting Document or similar, and configure the other settings as desired.
  3. Create an Action Button field to contain the Merge Document action.
  4. Name the button Merge Supporting Material or similar.
  5. Select the Execute Actions checkbox and click Add Action. The Actions wizard opens.

Create the Merge Document Action

Use the Actions wizard to create a new Merge Document action.

  1. Click Create Merge Document Action.
  2. On the General tab, add a name and description for the action.
  3. Configure the settings on the Data Source tab:
    1. For the source file location, select Local File Field and choose whichever field holds the Word documents.
    2. Store the merged document in the Final Supporting Document field that you created.
    3. Overwrite any existing files in the field.
    4. For the default file name, use $id supporting-doc.
  4. Configure the settings on the Options tab:
    1. Select PDF for the output format.
    2. For page breaks, choose to concatenate the documents.
    3. Include MS Word files during the merge, and merge the documents before they're converted to PDF.
    4. Use the MS Word installed on the current server.
  5. Click Finish.

Finish the Setup

  1. Configure the rest of the action button as desired and save it.
  2. Add the fields you created to the layout.
  3. For an Incident record with Word files in the relevant field, click Merge Supporting Material. The files are merged into a single PDF with page numbers and a unified style, and it's placed in the Final Supporting Document field using the default file name.

Related articles