Templates

❗️

Webhook plugin is deprecated.

Please use the Automation Rules feature instead, unless you're on the old Targetprocess version (older than Targetprocess v3.13.0) or on a local On-Site installations.

Fields available in templates

If you mix several entity types (e.g. User Stories and Bugs) in one Webhook, you can only use general fields.
However if you use only one type, you are free to use both general and entity-specific fields.
In Targetprocess 3.8.2+ you can even use custom fields.

📘

Full list of available fields

Nested collections (e.g. Comments) are not supported.

How to decide if you need a template?

Templates serve the following purposes:

  • you can form the outgoing message in the pattern, which is understandable for the chosen external resource;
  • you can send only the data you’re interested in;
  • you can use conditions, so the exact content of the message would depend on the data which triggered this event.

If you don’t use a template, the outgoing message would be formed automatically in either JSON and XML format (depending on what you’ve specified as a content type).

🚧

Some resources (e.g. Slack) expect data to be send in a specifi format (e.g. { “text”: “This is a line of text.” }), so using a template would be mandatory in this case.

Functions

FunctionDescritionExamplesAvailable in
Default Liquid functionsLiquid functions.
Note: names should start with a capital letter
{{CreateDate | Date:"MM/dd/yyyy"}}
{{EntityTypeName | Remove:'Tp.BusinessObjects.'}}
{{Name | Upcase}}
3.5.4+
DateTime AddDays (DateTime date, int days)Returns a new date with the number of days added. The number of days can be positive or negative.{{CreateDate | AddDays: 7}}
{{ Now | AddDays: -1}}
3.7.3+
DateTime Now ()Returns the server’s current date and time.{{Now}}3.7.3+
DateTime LastSunday (DateTime date)Returns the closest start of the week (last Sunday) for a given date.{{StartDate | LastSunday}}
{{Now | LastSunday}}
3.7.3+
String ToPlainText (string htmlText)Strips all the tags and decodes html string.{{Description | ToPlainText}}3.7.3+
Int DiffDays (DateTime date1, DateTime date2)Returns amount of days between two dates (for native date fields){{PlannedEndDate | DiffDays: Previous.PlannedEndDate}}
{{LastStateChangeDate | DiffDays: CreateDate}}
{{Now | DiffDays: CreateDate}}
3.11.0+
Int DiffDaysFromString (string date1, string date2)Returns amount of days between two dates (for date custom fields){{DATE_CF | DiffDays: Previous.DATE_CF}}
where DATE_CF is a custom field of a type Date
3.12.6+

🚧

It's not possible to get amount of days between a native date field and date custom fields.

Conditions

The general structure of conditions is the following:

{% if <CONDITION A> %}
Template A
{% elsif <CONDITION B> %}
Template B
{% elsif <CONDITION C> %}
Template C
...
{% else %}
Template X
{% endif %}

You can find more about conditions at Liquid documentation.

Here is an example of a simple template with a condition:

{% if {{ProjectName}} == 'Core Development' %}
Here is something for developers: 
{% else %}
Not for developers:
{% endif %}
#{{ID}} {{Name}} {{EntityUri}} in Project {{ProjectName}}

More examples

You can find examples of templates at Use Cases pages: