Upload Templates From Microsoft Word With The DOCX Feature

Introduction

S-Docs provides users the opportunity to efficiently upload .docx files through the DOCX feature. This feature allows you to:

  1. Easily import pre-existing Microsoft Word templates that you don't want to rebuild from scratch in the Template Editor
  2. Leverage Microsoft Word features like Restricted Editing, Table of Contents, and Redlining
  3. Create complex and beautiful templates without any knowledge of HTML

This guide will teach you how to create DOCX templates, use the correct merge field syntax, and upload your DOCX files templates to S-Docs.

Generating DOCX Documents via S-Docs

Using .docx files with Microsoft Word is incredibly advantageous if you’re trying to increase your documentation generation.  Let’s start by creating a new S-Docs template. Click on the Template Format drop-down menu and choose DOCX. Click Save.

Next, head to the template editor like you would with other templates. Normally, you would be able to make changes to the source code here, but with the DOCX upload feature, all you have to do is upload the .docx template file that you’ve already created!

Let's start by putting a merge field into our template. From the template detail page, click the Template Editor button.

Then, click Insert Field and select a merge field.

Rather than inserting the field into the typical source code editor, you will select a field and click Copy to Clipboard and paste it into your Word document where desired.

Once you’ve pasted the merge field in your Word document, return to the template editor. The screen should look like this:

Select "Choose File" and upload the Word document you have been working with. After selecting the file, you will see a message indicating that your file is uploading. In a matter of seconds, your template will successfully upload.

Congratulations! You can now generate your DOCX documents using your created S-Docs template.

Note: The best workflow to build DOCX documents is to have your browser and Word open side-by-side. In addition to using copy and paste, you can also drag-and-drop merge fields into your DOCX document without having to switch between windows.

Uploading Bulk DOCX Templates

You can create a large number of DOCX templates at one time using the Bulk DOCX Upload feature. The Bulk DOCX Upload page can be accessed through the S-Docs Setup page.

To navigate to the S-Docs Setup page, click the App Launcher in the upper left corner, type "S-Docs" into the search field, then click S-Docs Setup.

Scroll down to the Other Pages section and click Go to Bulk DOCX Upload Page.

The Bulk DOCX Upload page appears as follows:

[1] To begin, choose the object that your templates will be related to.
[2] Next, click Choose Files to select as many DOCX templates as you'd like. Each file chosen will create an S-Docs template.
[3] Check the Legacy syntax checkbox if you're using the older DOCX syntax, which is no longer supported.

Syntax

Since first launching our DOCX feature, we have updated the syntax. The old syntax is still available when the “Legacy Upload” checkbox is checked on the DOCX file upload page, but no longer supported.

General DOCX Syntax

Note: DOCX syntax also applies to PPTX and XLSX documents.

As part of the update, brackets are now required around all S-Docs syntax in DOCX templates, which results in a better output of your template.

[{{!<lineitems>
<tableformat>]

//Your Table Here

[</tableformat>
<listname>opportunitylineitems</listname>
<column>name</column>
<column>quantity></column>
<column prefix="$" format-number="#,###.##">listprice</column>
<column prefix="$" format-number="#,###.##">totalprice</column>
</lineitems>}}]

 

Your styling table needs 3 rows as shown above:

  1. Header row with intended header text
  2. Odd row with placeholder text
  3. Even row with placeholder text
Note: In version 4.515 support was added for using BRACKETOPEN and BRACKETCLOSE in a template to include the [ and ] characters in a generated DOCX file.

Render Statements

If you’re importing a DOCX template that uses render statements, you will need to use brackets there too.

[<!--RENDER={{!Contact.Phone}}=="123-456-7890"-->]
[{{!Contact.Name}}] can be reached at [{{!Contact.Phone}}]. This is never true.
[<!--ENDRENDER-->]


[<!--RENDER={{!Contact.Name}}=="Tim Barr"-->]
[{{!Contact.Name}}] can be reached at [{{!Contact.Phone}}]. This may or may not be true.
[<!--ENDRENDER-->]


[<!--RENDER=1!=2-->]
This is always true.
[<!--ENDRENDER-->]


[<!--RENDER=1==2-->]
This is never true.
[<!--ENDRENDER-->]

Note: You cannot have RENDERS on the same line as the LINEITEMS block.

Named Queries

If you're using named queries in your DOCX template, you'll need to convert them to the DOCX format. If your named query looked like this:

<!--{{!<LineItemsSOQL>
...
</LineItemsSOQL>}}-->
{{!myQuery1.fieldname}}

You'd need to update it to this syntax:

[{{!<LineItemsSOQL>
...
</LineItemsSOQL>}}]
[{{!myQuery1.fieldname}}]
Note: DOCX templates support the named query filter and offset features. Please visit the named query article linked above for more information about these features.

Rich Text Images

You can display images stored in rich text fields by surrounding the merge field in three curly braces instead of two, as shown below.

[{{{!Object.FieldName}}}]

To adjust the image dimensions, navigate to the Document Options tab of the template editor, scroll down to the Other Options section, and input your desired dimensions into the Rich Text Image Dimensions field, as shown below.

Note: This field governs the size of all images merged into your DOCX template from rich text fields.

Rich Text Font

Fonts and font sizes are not pulled from Salesforce rich text fields into your DOCX document - they will simply match Microsoft Word's "Normal" style. If you want your document to display the font from your rich text field, you can either change Microsoft Word's "Normal" style to match the desired font/font size, or use the font-family and font-size merge field attributes. For example, if your rich text field is written in Arial font at size 12, your merge field might look like this:

[{{!Object.FieldName font-family="Arial" font-size="12"}}]

Tags: , ,

Was this helpful?