Skip to content

Latest commit

 

History

History
74 lines (52 loc) · 5.86 KB

File metadata and controls

74 lines (52 loc) · 5.86 KB
description
How to Format Rules with a Custom-Built Solution for Basic Use Cases

Simple

When we started to introduce placeholders we defined limited sets of placeholders, but the system was just too inflexible for users. To make it more flexible, a new system was introduced, with 4.2.0. This gives access to all properties.

The syntax is very easy:

${<TYPE>_<PROPERTYAME>} or 
${<TYPE>_<PROPERTYAME> | filters} or 
$<TYPE>_<PROPERTYNAME>

The <TYPE> is a prefix that has been used for backwards compatibility and users may use whatever they want but the best recommendation is to use prefixes that fit the type of event, for example, content or asset. The <PROPERTY> is the full path to the property in the event, for example:

  • $CONTENT_TYPE: Created
  • $CONTENT_SCHEMAID.NAME: my-schema
  • $CONTENT_DATA.CITY.en: Munich

{% hint style="info" %} If possible, always use the first variant with the brackets ( { and } ). {% endhint %}

Special Placeholders

Furthermore, there are still some special placeholders for backwards compatibility or to grant access to information that is not directly part of the event.

Event Description New Alternative
$APP_ID The id of your app (GUID). ${EVENT_APPID.ID}
$APP_NAME The name of your app. ${EVENT_APPID.NAME}
$USER_ID The id of the user (or client). ${EVENT_USER.ID}
$USER_NAME The display name of the user (or client name). ${EVENT_USER.NAME}
$USER_EMAIL The email address of the user (or client name). ${EVENT_USER.EMAIL}
$TIMESTAMP_DATE The date when the event has happened (usually different from the time when the rule is executed) in the following format: yyyy-MM-dd.
$TIMESTAMP_DATETIME The date when the event has happened (usually different from the time when the rule is executed) in the following format: yyyy-MM-dd-hh-mm-ss.
Event Description New Alternative
$SCHEMA_ID The name of the schema. ${EVENT_SCHEMAID.ID}
$SCHEMA_NAME The name of the schema. ${EVENT_SCHEMAID.ID}
$CONTENT_URL The URL to the content in the administration tool.
$CONTENT_ACTION The content action, e.g. CityContentCreated. ${EVENT_TYPE}

Special Placeholders for Comment Events

EventDescriptionNew Alternative
$MENTIONED_IDThe id of the mentioned user.${EVENT_MENTIONEDUSER.ID}
$MENTIONED_NAMEThe display name of the mentioned user.${EVENT_MENTIONEDUSER.NAME}
$MENTIONED_EMAILThe email address of the mentioned user.${EVENT_MENTIONEDUSER.EMAIL}S

Special Placeholders for Asset Events

Event Description
$ASSET_URL The download URL of the asset.

Filters

This simple syntax also supports a few function filters when using the new syntax:

${<TYPE>_<PROPERTYAME> | filters} 

The following table uses:

NameDescriptionExample
lowerConverts the input to lowercase.

Hello World

=> hello world

upperConverts the output to uppercase.

Hello World

=> HELLO WORLD

escapeEscapes the input to a JSON string.Hello "World"
=> Hello \"World\"
slugifyConverts the input to a slow, which can only contain a-z0-9 and -.

Hello World

=> hello-world

trimRemoves whitespaces at the start and end of the input. Hello World
=> Hello World
timestampParses the input as ISO8601 datetime string and converts it to a unix timestamp using milliseconds.2023-01-10T10:41:32
=> 1673347292000
timestamp_secParses the input as ISO8601 datetime string and converts it to a unix timestamp using seconds.2023-01-10T10:41:32
=> 1673347292

Filters can also be combined:

${CONTENT_DATA.CITY.en | uppercase | escape}