KB-1819 Word Doc from Template Smart Service fails to replace placeholders

Symptoms

When using the Word Doc from Template Smart Service with a runtime template, some substitution keys (placeholders surrounded by three pound symbols, e.g. ###section###) are successfully recognized in the setup tab but are not replaced in the output document.

Cause

Microsoft Word is automatically formatting the text which creates extra XML tags in the template. If the XML formatting of the template and the runtime template do not match, then the substitution key will not be replaced.

This issue can occur even if Microsoft Word has not reported any spelling or grammar errors.

This issue has been reported to the Appian Product Team. The reference number for this issue is AN-125621.

Action

To ensure that neither the base template nor the runtime template have malformed XML tags, perform the following steps for all templates:

  1. Copy the entire contents of the template docx and paste it into a new docx.
  2. Before saving the new document, disable spelling and grammar checks in Microsoft Word. These settings can be found at File > Options > Proofing > Check spelling as you type / Mark grammar as you type.
  3. Save and upload the new document to Appian.

To determine if a template document has malformed XML, save the template docx as XML in Microsoft Word and investigate the XML. Properly formed XML will have contiguous substitution keys including the pound symbol delimiters. For example, the XML for substitution key "###sectionNumber###" may look like this:

<w:r><w:t>###sectionNumber###</w:t></w:r>

If the XML is malformed, the substitution key will be interrupted with extra XML tabs:

<w:r><w:t>###section</w:t></w:r><w:r w:rsidR="00CA73EC"><w:t>Num</w:t></w:r><w:bookmarkStart w:id="0" w:name="_GoBack"/><w:bookmarkEnd w:id="0"/><w:r w:rsidR="00CA73EC"><w:t>ber</w:t></w:r><w:r><w:t>###</w:t></w:r>

For more information, review the Word Doc From Template documentation. 

Affected Versions

This article applies to all versions of Appian.

Last Reviewed: March 2019

Related
Recommended