Word templates allow you to customize how object information is exported to ensure document uniformity and adherence to organizational standards.
Word templates are also used for PDF exports. To enable Word or PDF exports, make sure to assign at least one Word template to your application using the exportTemplateKey property in the applications asset.
In a new Microsoft Word document, you can create:
- Per-object templates: These templates are replicated for each individual object in the export. Each exported object gets its own page based on the defined template layout. Use this when you need detailed, one-by-one documentation.
- Object list templates: These templates include sections that display information about all exported objects in a single, combined layout, typically as a list or table. Use this for overviews, summaries, or tabular reports.
Creating templates
A Word template can consist of two types of elements:
- Static text which will be exported the way you see it.
- Components which are replaced by real data in the export.
Components
Components are created using the JSON format in double angle brackets. Their order influences the order of the information on the page.
<<{Component in JSON format}>>
Each component must have a type property to specify what kind of data will be displayed.
Example:
<<{ "type": "objectName", "useNumbering": true, "styles": [ "1 Number Heading", "2 Number Heading", "3 Number Heading" ] }>>
Microsoft Word often automatically replaces standard quotation marks with regional or “smart quotes” (e.g., “ ” or ‘ ’), which may not be valid in code. Make sure to use straight quotation marks for code:
- Double quotes: "" These are the proper characters recognized in code editors.
Conditions (Hide when empty)
All components can have conditions attached to them, such as hiding the whole section when there is no data.
Let’s take a look at an example:
<<{ "type":"text","Text":"Paragraph 1","style":"block","conditions": [ { "type":"attribute","value":"packageKey_attributeTypeKey","operator":"not null" } ] }>>
<<{ "type":"attribute","attributeType":"packageKey_attributeTypeKey" }>>
The first component will be displayed only when the specified attribute (packageKey_attributeTypeKey) is not empty ("operator": "not null").
Component types
There are two types of components available:
- Object detail section components: These components are inserted into the Object Detail Section, which gets replicated for each exported object. They can also be used for headers and footers.
- Multi object components: These components are replaced with a list of the same type of information on all objects in one section. For example, all object names, followed with all descriptions, etc.
Templates fields
Another way of adding components to a Word template is using the <<Templates fields>> section. The <<Templates fields>> section contains all components, which are simply referenced in the template itself. For example:
<<Object details>>
<<[1]>>
Attributes:
<<[2]>>
<</Object details>>
<< Template fields >>
[1]: <<{ "type": "objectName", "useNumbering": true, "styles": [ "1 Number Heading", "2 Number Heading", "3 Number Heading" ] }>>
[2]: <<{ "type" :"attribute", "attributeType": "definition", "style": "Normal" }>>
<</ Template fields >>