Last updated: 15.09.2020

Applies from: 2018.12.00 and later

Tag syntax – HTML

The tags in HTML reports come from the Delivery class. Tags from other classes need the prefix

in the Class/prefix column of the tables in the Tag List. The prefix is separated from the tag by a dot, for example Customer. CUS_Name.

Syntax: @Model.prefix.tag

In this example, which retrieves the order number, no prefix is needed because DEL_Id is in the Delivery class.

Copy code

Example

@Model.DEL_Id

In the example below, which retrieves the telephone number for the transport company from the office settings, OFF_PhoneNo is in the Office class, which must therefore be used as a prefix.

Copy code

Example

@Model.Office.OFF_PhoneNo

Varning!

If you add a tag to a HTML report with the wrong prefix, or misspell the tag, the notification will not work and an error message stating that there is no report will be displayed when the notification is generated.

Lists

There may be many instances of some items in an order, such as packages and shipments. In order to be able to display information about such objects in the report, the tag has to be combined with a list tag so that all the instances of the item are counted. The result is a list with one or more entries.

The list in the report can be structured in various ways. A heading can be entered for the whole list, or a description can be written that repeats on each line. It is also possible to combine several tags belonging to the same list, thus creating a list with, for example, the package ID and the weight of each package in an order.

The entries in the list do not have to be numbers, but can also be text, for example PAC_Text, which returns the free text field for the packages in an order.

Syntax:

Optional text

@foreach(var item in Model.list tag.ActiveItems)

{

<text>Optional text: @item.tag</text><br/>

}

A list of some of the lists that exist, and the associated tags, can be found in the List of tags.

Example 1

Copy code

List of package IDs and a description for each line

@foreach(var item in Model.Packages.ActiveItems)
{
   <text>Package ID: @item.PAC_PackageId</text><br/>
}

Returns the list in the following format

Package ID: 123456

Package ID: 356789

Package ID: 986554

Example 2

Copy code

List of package IDs and a heading for the whole list

<b>Packages</b><br>
@foreach(var item in Model.Packages.ActiveItems)
{
   <text>@item.PAC_PackageId</text><br/>
}

Returns the list in the following format

Kollin

123456

356789

986554

Example 3

Copy code

List of package IDs, weight and goods text

<b>Packages</b><br>
@foreach(var item in Model.Packages.ActiveItems)
{
   <text>@item.PAC_PackageId: @item.PAC_Weight kg (@item.PAC_Text)</text><br/>
}

Returns the list in the following format

Kollin

123456: 1.200000 kg (Folder with documents)

356789: 3.400000 kg (Fragile)

986554: 5.600000 kg (Accessories)

If one of the packages does not have any goods text, an empty bracket is displayed.

Figures

Numbers are stored with six decimal places in the Opter database. To round to fewer than six decimal places, enter a format tag and the number of desired decimal places, based on the format 0.00, in the tag that returns the number. The number of zeros entered after the decimal point defines the number of decimal places.

To exclude unnecessary zeros at the end of numbers (2.7 instead of 2.70), but print the decimal if it is not a zero (2.73), enter # signs for the number of decimal places that are to be shown.

Syntax: @Model.prefix.tag for numeric value.ToString("0.######")

Example 1

Copy code

Always displays two decimal places whether they have a value or not

<b>Weight</b><br>
@foreach(var item in Model.Packages.ActiveItems)
{
   <text>@item.PAC_Weight.ToString("0.00") kg </text><br/>
}

Returns a list in the following format

Vikt

2.00 kg

2.70 kg

12.74 kg

Example 2

Copy code

Displays up to three decimal places if they have a value

<i>Weight</i><br>
@foreach(var item in Model.Packages.ActiveItems)
{
   <text>@item.PAC_Weight.ToString("0.###") kg </text><br/>
}

Returns a list in the following format

Weight

2 kg

2.7 kg

12.738 kg

Example 3

Copy code

Always displays two-digit integers and two decimal places

<u>Weight</u><br>
@foreach(var item in Model.Packages.ActiveItems)
{
   <text>@item.PAC_Weight.ToString("00.00") kg </text><br/>
}

Returns a list in the following format

Weight

02.00 kg

02.70 kg

12.74 kg

Images

You can add images to reports, such as logos specified in the office settings.

Syntax: <img src="data:image/png;base64,@(Convert.ToBase64String(Model.prefix.tag))">

Copy code

Retrieves the large image from the office settings

<p>Hello,</p>
<p>Your order from @Model.StartAddress.ADR_AddrLine1 is on its way.</p>
<p>Best wishes,</p>
<p>
<img src="data:image/png;base64,@(Convert.ToBase64String(Model.Office.OFF_LargeImage))">
</p>
</body>
</html>

Returns

Hello,

Your order from Opter is on its way.

Best wishes,

 


See also

Creating reports for notifications

Reports (window)

Report editor, window