Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 2 Next »

Field Tokens

Fields are output by specifying their name inside double curly braces:
{{ FIELD_NAME }}

Simple Formatting Flags

Extra formatting can be applied simply by including some formatting flags (included with \f)

  1. {{ FIELD_NAME \f dd/MM/yyyy }}

  2. {{ $currentdate \f dd/MM/yyyy }}

  3. {{ FIELD_NAME \f ##,###.## }}

  4. {{ FIELD_NAME \f “USD TO WORDS” }}

  5. {{ FIELD_NAME \f “GBP TO WORDS” }}

  6. {{ FIELD_NAME \f “UPPERCASE” }}

  7. {{ FIELD_NAME \f “lowercase” }}

Format Chaining - When required you can "chain" flags to include multiple formatting options. To do this different formatting options are included with a | symbol inbetween them.

  1. {{ FIELD_NAME \f “USD TO WORDS” | “UPPERCASE” }}

  2. {{ FIELD_NAME \f “usd to words” | ‘lowercase’ }}

Advanced Formatting Flags

These are some more advanced formatting flags:

flagname

behaviour

notes

/f qrcode(<size>)

Outputs the value of the Token as a QR Code.

Size must be an integer value which will be the width and height of the QR Code in Pixels. For example: {{ FIELD_NAME \f qrcode(200) }}

n.b. Formatting flags will ignore case and special characters at the beginning and at end. So all of the below are identical behaviour:

  1. \f “lowercase”

  2. \f LOWERCASE

  3. \f ‘UPPERCASE’

  4. \f uppercase

  5. etc…

$VARIABLE

Variables are used to specify values which are no data stored on the system but instead dynamic values such as: current date, current user name and special tags which create and embed share links or other dynamic features:

  1. {{ $VARIABLE }} - variable should always start with $

  2. {{ $VARIABLE \f FLAG }} - formatting flags can also be included when using variables.

Here are the currently support list of Variables:

variable name

behaviour

notes

$currentdate

$currenttime

$currentuser

This returns a reference to the Contact of the current user (i.e. the one creating the document from the template), you can then use '.' notation to drill into all the usual data of the current user.

$currenttenant

This returns a reference to the Contact of the current tenant (i.e. the company or org the AgileCase account belongs to), you can then use '.' notation to drill into all the usual data of the current tenant. This is useful for getting common data for letterheads such as company addresses, phones numbers etc. You can store any global information as custom fields against the Tenant record and then output it using this variable.

$formlink(<formid>)

Outputs a URL linking to a published Form.

Learn more about Shared Forms in the AgileCase v2 documentation.

$importdoc(<formid>)

Outputs the result of one template within another. i.e. for common elements you want to have in a single place but reuse across templates. Most commonly used for headers and footers.

Only available in MS Word Document format templates. Has no effect in other template formats.

$formlink supports a special flag "/NEW" which forces a new Shared Form instance to be created. When /NEW is omitted the form is reuse an existing Shared Form instance if one exists, or create one if it does not.|

OPERATORS

Operators are supported for IF and WHERE conditional logic.

  1. ==

  2. = (same as ==)

  3. !=

  4. >

  5. >=

  6. <

  7. <=

  8. contains

  9. not contains

You will see examples of usage below under IF and WHERE.

IF Logic

If statements are used to optionally output the content in between them. Any combination of other tags and text can be included inside a IF condition.
Simple:

  1. {{ if FIELD_NAME = 100 }} The content you want to see if the condition is true {{/if}}

  2. {{ if FIELD_NAME != 100 }} The content you want to see if the condition is true {{/if}}

  3. {{ if FIELD_NAME > 100 }} The content you want to see if the condition is true {{/if}}

  4. etc

With variable:

  1. {{ if FIELD_NAME = $currentdate }} The content you want to see if the condition is true {{/if}}

  2. {{ if $currentdate = 20/12/2022 }} The content you want to see if the condition is true {{/if}}

WHERE

Where statements are used to summarize other data in a multi-row custom field group. For example to SUM all columns in a table WHERE a specific test is met.

Where Flags:
Where support the following flags.

  1. \f SUM(FIELD_NAME)

  2. \f COUNT

SOME_VALUE - object field value from array with what it will be compared
SOME_OTHER_FIELD_NAME - will be a field from the array

Examples:

  1. {{ where FIELD_NAME = SOME_VALUE \f SUM(SOME_OTHER_FIELD_NAME) }}

  2. {{ where FIELD_NAME = SOME_VALUE \f COUNT }}

  3. {{ where FIELD_NAME \f COUNT }}

  4. {{ where FIELD_NAME \f SUM(SOME_FIELD ) }}

In this part {{ where FIELD_NAME = SOME_VALUE \f SUM(SOME_FIELD) }} MERGE_FIELD can be a field in an array or the array itself:

  1. {{ where customfields.price.options = SOME_VALUE \f SUM(SOME_FIELD ) }}

  2. {{ where customfields.price \f SUM(SOME_FIELD) }}

In this part {{ where FIELD_NAME = SOME_VALUE \f SUM(SOME_FIELD) }} which field to calculate

CALCULATE

Supports various expressions:

  1. x + y

  2. x - y

  3. x * y

  4. x / y

  5. (x + y) * z

  6. etc

Can merge fields with regular numbers, examples:

  1. {{ calculate }} {{FIELD_NAME }} * 10 {{/calculate}}

  2. {{ calculate }} {{ FIELD_NAME }} - {{ FIELD2_NAME }} {{/calculate}}

  3. {{ calculate }} 5 - {{ FIELD_NAME }} {{/calculate}}

  4. {{ calculate }} ( {{ FIELD_NAME }} - {{ FIELD2_NAME }} ) * {{ FIELD3_NAME }} {{/calculate}}

  5. etc

CALCULATE + WHERE

{{calculate}} {{ where FIELD_NAME = SOME_VALUE \f SUM(SOME_FIELD) }}
+ {{ where FIELD_NAME = SOME_VALUE \f SUM(SOME_FIELD) }}
+ {{ where FIELD_NAME = SOME_VALUE \f SUM(SOME_FIELD) }}
{{/calculate}}

CASE

Here MERGE_FIELD is the field by which to compare
{{ case MERGE_FIELD }}
{{ when 1 }} If FIELD_NAME = 1 you will see it {{/when}}
{{ when 2 }} If FIELD_NAME = 2 you will see it {{/when}}
{{ when 3 }} If FIELD_NAME = 3 you will see it {{/when}}
{{/case}}

You can also use multiple values for comparison separated by commas:
{{ case FIELD_NAME }}
{{ when 1 }} If FIELD_NAME = 1 you will see it {{/when}}
{{ when 2,3 }} If FIELD_NAME = 2 or 3 you will see it {{/when}}
{{/case}}

FOREACH

Here FIELD_NAME should be array of objects
SOME_FIELD will be a field from the array

Examples:
{{ foreach FIELD_NAME }} {{ SOME_FIELD }} {{/foreach}}

For SOME_FIELD you can specify both: a long path and a short one
{{ foreach customfields.price }} {{customfields.price.options}} = {{numeric}}{{/foreach}}
{{ foreach customfields.price }} {{options}} = {{customfields.price.numeric}}{{/foreach}}

FOREACH + CASE + WHERE + IF + CALCULATE

Also inside FOREACH should work all of logical items:
{{ foreach FIELD_NAME }}
{{SOME_FIELD}}
{{ if SOME_FIELD = 10 }} The content you want to see if the condition is true{{/if}}
{{/foreach}}

  • No labels