Skip to main content
Version: Next

Helpful Functions

These helper functions provide simple solutions to some fields and options used in advanced collection reports.

_now

A datetime object with the date/time at the moment of report generation. This can be helpful to track the time that an export is performed. It can also be utilized with a Date Time Option. The general syntax is as follows:

+++= _now.dateTimeOption +++

tip

Output the current day (using local time zone) that the export was performed:

+++= _now.shortLocal +++

_html

Allows HTML formatting to be embedded in the document. Useful when outputting custom fields that are rich text or comments. The HTML helper has two options to allow more control over the desired output font and font size. The syntax is as follows:

+++HTML _html(value, Desired Font, Desired Font Size) +++

  • Desired Font is optional. The default is Arial.
  • Desired Font Size is optional. The default is 12pt.
tip

Suppose there is a rich text custom field with a key of ABCDE. To output the name of this field and the value in HTML format:

+++HTML _html(customFieldByKey.ABCDE.value) +++

_plain

Exports a value as plain text. Using this with custom fields that are rich text or comments may export and show HTML tags and markdown characters. The syntax is as follows:

+++= _plain(value) +++

tip

Suppose there is a rich text custom field with a key of ABCDE. To output the name of this field and the value in plain text format:

+++= _plain(customFieldByKey.ABCDE.value) +++

_get

The _get helper is useful, in combination with the FOR-loop, to grab a specific value with built-in error handling for null or non-existent values. If desired, you can specify the value to return if no value is found. The syntax (within a for-loop) is as follows:

+++= _get($event, 'eventDetailByKey.keyhere.option', Desired Null Value) +++

The Desired Null Value is optional. By default, null values return as N/A.

tip

Suppose a collection has numerous types of events added, and you desire to:

  • Only export the Behavior Profiles events.
  • Only output the SSN (key of ABCD) field.
  • Manually show the field name as Social Security Number in bold.

To achieve this, use the following code:

+++FOR events IN _keep(items, ‘eventTypeTitle’, ‘Behavior Profiles’)+++  // Start the loop.

Social Security Number

+++= _get($events, 'eventDetailByKey.ABCD.value') +++ // Get the SSN data field.

+++END-FOR events +++ // Close the loop.

_omit

Filters out items in a list by comparing the values of the given key. Used in a FOR-loop.

The syntax is:

_omit(list, ID, id1, id2, ...)

Where:

  • list is a filterable list (e.g., items, eventDetails, customFields).
  • ID is the field you wish to filter by.
  • id1, id2, etc. are the values to filter by.
tip

Loop through the events (items) in a collection and exclude any event that is under "Behavior Profiles":

+++FOR events IN _omit(items, ‘eventTypeTitle’, ‘Behavior Profiles’)+++  // Start the loop.

Social Security Number

+++= _get($events, 'eventDetailByKey.ABCD.value') +++ // Get the SSN data field.

Short Description

+++= _get($events, 'eventDetailByKey.EFGH.value') +++ // Get the Description data field.

+++END-FOR events +++ // Close the loop.

_keep

Keeps only the items in a list by matching the values of the given key. Used in a FOR-loop.

The syntax of the _keep helper is as follows:

_keep(list, ID, id1, id2, ...)

Where:

  • list is a filterable list (e.g., items, eventDetails, customFields).
  • ID is the field you wish to filter by.
  • id1, id2, etc. are the values to filter by.
tip

Loop through the events (items) on a collection and only include any event that is under "Behavior Profiles":

+++FOR events IN _keep(items, ‘eventTypeTitle’, ‘Behavior Profiles’)+++  // Start the loop.

Social Security Number

+++= _get($events, 'eventDetailByKey.ABCD.value') +++ // Get the SSN data field.

Short Description

+++= _get($events, 'eventDetailByKey.EFGH.value') +++ // Get the Description data field.

+++END-FOR events +++ // Close the loop.