Page tree
Skip to end of metadata
Go to start of metadata

Overview

Document Transformations in AMS are used to convert a message into Word, Excel or PDF documents.

Word files can be in either doc or docx format. 

The first step is to design the format of the output document. This is done by creating a Word document in Microsoft Word and inserting Mail Merge Fields where data from the message is to be placed.  This file is then uploaded into AMS by selecting the file name and file type.

As messages are received and processed by the Route, AMS will create a document based on the configuration and deliver this as an email attachment.

Designing The Document Template

A Word document is used as a template to generate new documents based on incoming messages and the data they contain.  This template will be combined (merged) with the data from an incoming message to generate the final output. The template document can be in either doc (Word 97-2003) or docx (Word 2007-2010) format. 

The template his created in Microsoft Word and contains Mail Merge Fields where the field names match the External Label of the data fields in the AMS Template from which the message was created.

When the incoming message is received and the Route processed, the Merge Fields are replaced with the specified data values from the message.

In addition, some Mail Merge Fields are required to control the flow of message data into the document or to alter the output like inserting a checkbox for example.

Inserting Mail Merge Fields

The process of inserting a Mail Merge Field into a document template is the standard Microsoft Word process (which may vary between versions of Office).

The only extra setting required is to specify the field as being a 'Mapped Field'.

  • In Word for Windows this is done by selecting the 'Mapped Field' option in the Field dialog box.
  • In Word for Mac this option is not present but can be specified by following the name of the Merge Field with the " \m" flag (note the extra space before the "\")
  • Placing a ' \m' after the field name will work in Windows as well.

The name of the fields must match the AMS field external label exactly, and the match is case sensitive.

Word 2003 on Windows Field Menu

Word 2003 on Windows Field Dialog

Word 2008 on Mac Field Dialog

Mail Merge Regions

For simple documents with no repeating areas of content, a document can be created that just contains mail merge fields.

For more complex messages and document, where sections of the content repeats, it is necessary to surround the desired section of the document with two special merge fields. These are <<TableStart:regionName>> and <<TableEnd:regionName>> where regionName is the external label of either the AMS Template or List Card (repeating card).

Regions Across Document Sections

Icon

Merge regions cannot span document sections. For example a region cannot span a page break.

Once these merge fields have been placed in the document it is possible to insert Merge Fields for the data items from the message.

The name of the Merge Field should match the name of the field or meta data to be inserted.

If a region represents a List Card, then the content of the region will be repeated for each item contained in the message for that List Card. In this way it is possible, for example, to create a repeating set of table rows within a document based on multiple data "rows" (List Cards) within the message.

Note that region fields are case sensitive and the 'TableStart' and 'TableEnd' must be as specified.

More detail on how to create repeating sections is provided below.

Nested Regions

Icon

Currently merge regions cannot be nested.

Repeating Content

Normally any part of a message that contains multiple items, such as entries from a List Card, will repeat the content within its associated region.

In order to repeat rows in a table then it is necessary to place the <<TableStart:regionName>> in the first column of the table, prior to any merged fields from the message.  Merge Field for the data to go in that cell and subsequent cells in the row.  Similarly, the {{<<TableEnd:regionName>>}} must be placed in the final column in the row, after the last Merge Field data item.

The following screenshot illustrates this:

 

 

Inserting Checkboxes

It is possible to configure a Merge Field to display as a checkbox.  The checkbox will be checked (crossed) if the value is matched.  To achieve this, enter the name of the Merge Field as <<CheckBox:fieldExternalLabel_[Value To Match]>>.

For example, if the AMS Field is a Choice Group with external label 'inspectionResult' and possible values 'Pass' or 'Fail' it is possible to have these displayed as checkboxes by adding two Merge Fields with field names <<CheckBox:inspectionResult_[Pass]>> and <<CheckBox:inspectionResult_[Fail]>>.

Icon

If the value to match for the checkbox contains whitespace the then § symbol must be inserted in place of the whitespace in the merge field.

For example if the choice to match from the the form for a field with external label 'action' is 'Stock Update Requested' then the checkbox merge field should be <<CheckBox:action_[Stock§Update§Requested]>>. To enter the § on Windows this is ALT key code 0167.

Inputting Key Codes

Icon
  • Place the cursor in the location where the special character is to be inserted
  • Activate the numeric key pad on the right of the keyboard by pressing Num Lock (upper right of keyboard). The Num Lock light on the keyboard will indicate that the numeric key pad is on.
  • This only works with the numeric key pad; if the number keys on the top of the keyboard are used then the characters will not appear.
  • An alternative method must be used on a laptop or computer without a separate numeric keypad
  • While pressing down the ALT key, type the four-digit code on the numeric key pad at the right edge of the keyboard.
  • The codes are "case sensitive." For instance, the code for § is ALT+0167.
  • If an International keyboard is activated, it is only possible to input codes with the ALT key on the left side of the keyboard.
  • Release the ALT key. The character will appear when the ALT key is released.

Inserting Images

To insert an image, such as a captured signature, use the field name format {<<Image:amsFieldExternalLabel>>}} e.g. <<Image:signature>>.

Inserting Message Details

To insert a value from the message details (if this has been enabled for the route) such as the mobile account username, prefix the message details item with the 'messageDetails' key using format <<messageDetails.itemKey>> e.g. <<messageDetails.username>>.

Inserting List Field Data

To insert a value from a selected list item, prefix the merge field with the external label of the list field followed by the external label of the desired list item using format {<<listFieldExternalLabel.itemExternalLabel>>}} e.g. to access the code field within a stock list field use merge label <<stock.code>>.

 

Dot Notation

Icon

AMS uses dot notation to access properties of messages. This means when accessing child values, i.e. those contained within other values like list items, message details or parent templates, use the parent items key or external label followed by a '.' then the child items key or external label.

Transformation Options

The settings for the document transformation allow you to control the output type and also how images and signatures are sized.

OptionDescription
MS Word Template

The Word document to use as the template. This file should contain the mail merge fields where the message data will be inserted. This file can be in doc or docx format.

Document Template File Format

Icon

If the output of the document transformation is PDF and you are having some problems with the quality, such as artefact or non solid fill areas, try changing the file format from one to the other, e.g. from doc to docx.

Filename

This is the filename of the transformed file. The value for this setting can contain a FreeMarker Template.

Valid Filenames

Icon

It is important the the suffix of the filename matched the type of the output document. For example if you select PDF as the output then the suffix of the filename value should be '.pdf'. 

Resize ImagesEnable this option to resize photos before inserting into the document.
Resize WidthThe width to target for the resize.
Resize HeightThe height to target for the resize.
Percentage ResizeEnable this option to resize based on a percentage of the original image size. Should be > 0 and <= 100.
Trim ImagesWill attempt to auto crop the image. Particularly useful for signatures to remove excess white colour surrounding the actual signature. This is applied before the image is resized.
Make Images TransparentEnable this option to be able to make a colour in the image transparent.
Transparent ColourThe name or rgb hex value of the colour to make transparent, e.g.white or #FFFFFF.
FlattenFlattens all layers in the image. This is useful if you are having issues with resized signatures in PDF documents.
Condition

The rules that must match for this document transformation to be applied.

Optional Document Attachments

Icon

Use a condition on the document transformation to optionally added extra files to a email. This is useful for example when doing an inspection and an extra form must be completed under certain conditions. Rather than having two routes setup and receiving two emails for each message this option allows you to receive a single email with an optional number of documents attached.

Image Resizing

Image resizing in AMS is done using ImageMagick. When images are resized, the order of operations to follow is:

  1. Trim: corresponds to the -trim option followed by +repage in ImageMagick.
  2. Resize: corresponds to the -resize option in ImageMagick.
  3. Flattencorresponds to the -flatten option in ImageMagick.
  4. Transparent: corresponds to the -transparent-color option in ImageMagick.

The image resizing settings currently apply to both photos and signatures as well as all kinds of devices.

On this page:

  • No labels