Creating a Rich Text Document Visit Report Template
Placeholders rich text document
In rich text document visit report templates, placeholders are defined by using text within markers. There are four types of placeholders. All of them are defined by using text within markers.
Notation | Placeholder Types |
---|---|
<<label name>> | Label |
##placeholder name## | Data item from a data set |
%%placeholder name%% | Image from a data set |
[[data set identifier]] | Data set identifier |
##DepartmentName## | <<Order>> | ##ServiceOrder## |
---|---|---|
##DepartmentAddress## |
<<OrderReference>> <<StartTime>> <<ServiceEngineer>> |
##ReferenceA## ##StartTime## ##Engineer## |
In this example <<Order>>, <<OrderReference>>, and so on, are labels (translatable text placeholders). ##DepartmentName##, ##ServiceOrder##, and so on are data items. In this case they are retrieved from the document level data set. As this document data set is generally available, these placeholders can be used anywhere in the document. For a list of all placeholders refer to appendix Placeholders for Visit Report Template.
NL Service Department | Service Order | SOO001407 |
---|---|---|
Het Torentje Binnenhof 19 2513 AA Den Haag, Zuid Holland The Netherlands |
Reference Start Time Service Engineer |
CUST_B_00012 15-8-2016 10:28 John Doe |
Layout
Basically, placeholders can be placed anywhere in the rtf document. So, a construction like Service order number ##ServiceOrder## has a start date of ##StartDate## is completely valid.
To be able to align elements, tabs or tables can be used. Tables can be inserted. Columns and or rows can be merged. For instance, a table of two rows with in the first row having one cell and the second row having three cells, is valid.
<<SomeTranslatedText>> | ||
##FieldA## | ##FieldB## | ##FieldC## |
The layout shown above retrieves Field A, B and C from the document data set.
To be able to display data from any other data set, a layout convention must be followed. All data set dependent placeholders must be inside a table. The data set identifier is key to the layout convention. The identifier must be placed in the first row in the first cell as the first text in this table.
Data set layout convention:
[[DataSetIdentifier]] | ||
<<HeaderTextA>> | <<HeaderTextB>> | <<HeaderTextC>> |
##FieldA## | ##FieldB## | ##FieldC## |
The data set convention defines three or more rows.
- The first row must hold the data set identifier (with [[ ]] markers). See also the data set definitions provided earlier in the document. When the data set identifier is not found, the table is handled as a layout table. See above. The data set identifier row is deleted after the merge is executed.
- The last row is replicated as many times as the data set holds records. Data placeholders of each replicated row is replaced with the corresponding data set record values. If the layout row contains data placeholders which do not correspond with the data set properties, replacement takes place using the parent data set. If no match is found in the parent data set, the placeholder is matched and possibly replaced with the document data set values.
- All other rows are header rows (zero, one or more). The header rows usually contain translatable text placeholders (<< >>). If the header rows contain data placeholders, data is replaced from the parent data set. If not applicable, placeholders are replaced with data from the document data set.
The minimum requirement for a data set table is two rows. Header rows are optional.
Example with two header rows:
[[MaterialCost]] | |||
<<Materials>> | |||
<<Quantity>> | <<ItemCode>> | <<ItemDescription>> | <<Amount>> |
##Quantity## | ##Item## | ##Description## | ##AmountOrCoverage## |
Example with no header rows:
[[MaterialCost]] | |||
##Quantity## | ##Item## | ##Description## | ##AmountOrCoverage## |
Nested Layout
To be able to represent parent/child relations, an extra convention is defined. In the case of activities and materials, if materials per activity must be presented, the material table must be nested in the activity table. Data sets have a structure to recognize if used as a child set. Instead of presenting all the material of a visit, only the material for the current activity are presented in the nested material tables.
In Word, this is easy to accomplish. Set the cursor in a table cell and select 'Add table' from the INSERT tab.
Nested data set layout convention:
[[DataSetIdentifier]] | ||
<<HeaderTextA>> | <<HeaderTextB>> | <<HeaderTextC>> |
##FieldA## | ##FieldB## | ##FieldC## |
[[DataSetIdentifier]] | ||
<<HeaderTextX>> | <<HeaderTextY>> | <<HeaderTextZ>> |
##FieldX## | ##FieldY## | ##FieldZ## |
Nested data set layout example:
[[Activities]] | ||
<<Activity>> ##Description## | ||
[[MaterialCost]] | ||
<<Materials>> | ||
<<Quantity>> | <<ItemCode>> | <<Description>> |
##Quantity## | ##Item## | ##ItemDescription## |
In the example above a material cost data set [[MaterialCost]] is nested in an activity data set [[Activities]]. The ##Description## is retrieved from the Activities data set. ##Quantity##, ##Item##, and ##ItemDescription## are retrieved from the MaterialCost data set.
Nested data set layout result example:
Activity Repair Box | ||
Materials | ||
Quantity | Item Code | Description |
6 pcs | AVDK17 | Chipboard |
3 box | AVDK1501 | Nails |
Totals
For each data set which represents costs, totals are calculated. In the default template, these totals are presented in the summary paragraph.
The placeholders Totalxxx and GrandTotal display values of all the cost of the selected activities. The detail lines of these costs do not necessarily have to be presented in the report. The TotalDetailxxx and GrandDetailTotal placeholders contain values only from the detail cost lines.
In this way, you can decide to display only the totals without details or display the detail and then displays the totals of these details.
Tools to edit the template
The template must be stored as an rtf file. Microsoft Word can handle this type of file although there are other text processing applications which also can edit this file type. After creating the template, the file must be stored as .rtf document.
Tools to edit the template
The template must be stored as an rtf file. Microsoft Word can handle this type of file although there are other text processing applications which also can edit this file type. After creating the template, the file must be stored as .rtf document.
Tip: Editing placeholders
When adding or changing placeholders, type out the entire placeholder in one action, do not change any individual characters, as Word sometimes adds some invisible markers in the rtf document. If so, the report merger is not able to interpret the template in the right way, and the placeholder is not replaced in the visit report. For placeholders which are spelled correctly but don't show the merged value, edit the template document, and retype the placeholder from start to finish including the front and end markers.
Tip: Web Layout View in MS Word settings
When using Word as editor, it is advisable to use the Web Layout view. From the Menu bar, select the VIEW tab, then click the Web Layout view. The table borders beyond the right margin of the paper are visible and can be edited.
Tip: view grid lines
The cell gridlines can also be displayed. By default, this feature is not enabled. Use the border layout option in the HOME tab and click View gridlines. Borders with no visible line, are represented as a dotted line.