Creating Html Visit Report Template

The template is stored as an html document. The complete default html template is shown in appendix Default Template for Visit Report. The default template is also available in LN in the Visit Report Templates (tsmdm5100m000) session.
Note: Html Visit Report Templates are supported in LN 10.5 and later versions, including LN Cloud Edition. The html templates can be used for LN Mobile Service for Windows, Android, and iOS. The rtf templates can only be used for the Windows version.

Placeholders html

In html visit report templates, placeholders are defined by using text within markers within the content of html tags or are defined as attributes of html elements. There are five types of placeholders. Three of them are defined by using text within markers. Two of them are defined by attributes on html elements.

Notation Placeholder Types
{{label name}} Label
##placeholder name## Data item from a data set
%%placeholder name%% Image from a data set
data-dataset=”dataset name” (attribute) Data set identifier
data-datasetrow=”dataset name” (attribute) Data set row identifier

Layout

Placeholders can be placed anywhere as part of the content of html tags of the document. So, the following construction is completely valid.

<span>Service order number ##ServiceOrder## has a start date of ##StartDate##</span>

The ##ServiceOrder## and ##StartDate## placeholder is replaced with the corresponding values of the visit in the actual visit report.

To define a data set section two attributes are used ‘data-dataset’ and ‘data-datasetrow’.

The ‘data-dataset’ attribute designates the element which is present if there are any records in the data set. When the data set has no records, the element is not displayed at all. If any header and footer content should only be displayed if there are any records, these should be contained within this element. If any header and footer content should always be displayed even if there are no records it should be outside of this element.

The ‘data-datasetrow’ attribute designates the element that is repeated for every record of the data set. Each repeated section is filled with the data values of one record of the data set. An element with the ‘data-datasetrow’ attribute is often defined within an element with a matching ‘data-dataset’ attribute.

Example 1

td_codeblock_example1

Red: the dataset element for LaborCost. This element and everything it contains is shown if there is at least one record in the LaborCost dataset.

Orange: the datasetrow element is repeated for each record in the LaborCost dataset.

Blue: elements which are part of the document dataset or parent dataset.

Assume service order ABC0001 started 1-8-2020 and has two labor costs DIG and FILL which lasted one and two hours respectively. The above template can result in the below visit report.

Service order number ABC0001 has a start date of 1-8-2020

Labor
Hours Task
1:00 Dig
2:00 Fill

To be able to represent parent/child relations the data set element of the child should be nested in the data set row element of the parent. These parent/child relations are present between activities and for example labor cost.

In the case of activities and labor cost, if labor cost must be presented per activity, the labor cost data set element must be nested in the activity data set row element. Data sets have a structure to recognize if used as a child set. Instead of presenting all the labor cost of a visit, only the labor cost for the current activity are presented in the nested labor cost section.

Example 2

td_codeblock_example2

Green: the datasetrow element is repeated for each record in the Activities dataset.

Red: the dataset element for LaborCost. This element and everything is shown if there is at least one record in the LaborCost dataset.

Orange: the datasetrow element is repeated for each record in the LaborCost dataset.

Blue: elements which are part of the document dataset.

Assume service order ABC0055 started 7-8-2021 and has two activities Check Cable and Correct Sign. The first activity Check Cable has two labor cost DIG and FILL which lasted one and two hours respectively. The second activity Correct Sign has no labor cost. The above template results in the below visit report.

Service order number ABC0055 has a start date of 7-8-2021

Activity Check Cable

ABC0055-1

Labor
Hours Task
1:00 Dig
2:00 Fill

Activity Correct Sign

ABC0055-2

No Document dataset elements

The Document dataset is the base data set and it has only one record. Dataset element and datasetrow element do not have to and should not be designated for the Document dataset.

Optional dataset element

Designating a dataset element with the ‘data-dataset’ attribute contains the datasetrow elements is optional. If only a repeating element needs to be displayed for the dataset only an element with the ‘data-datasetrow’ attribute can be designated. This is shown in example 2. For the Activities dataset no ‘data-dataset’ attribute is used, only a ‘data-datasetrow’ attribute designates the element which should be repeated for each record in the Activities dataset.

Parent data values in child

If a dataset or datasetrow element contains data placeholders which do not correspond with any of 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. This is shown in example 2. For the Activities datasetrow the service order code is printed in combination with activity line, using the ##ServiceOrderCode## placeholder of the document dataset.

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 displays 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.

Editing the template

To edit a html visit report template basic knowledge of html is required. A html file can be edited by opening it in a text editor but there are many more sophisticated tools available to create and edit html files.

Styling and Images

No external files are supported by the template. Styling and images should be embedded within the template file. Styling in the form of CSS can be defined inline by using the style attribute inside html elements or internally on a document level by using a style element in the head section. Images can be embedded in the html document itself in various ways.

An example of embedding an image can be found in the default html template in LN. This template can be imported and downloaded from session Visit Report Templates (tsmdm5100m000), or downloaded from session Additional Files (ttadv2570m000, additional file tssocLN_Mobile_Service_Visit_Report_Template.html).