Templating is widely used in PYXI. Blocks of text displayed in Forms and the content of Pages are the best starting points to consider.

A template is usually evaluated in the context of a specific record. The importance of this becomes apparent as soon as you consider the primary rules of how a template is processed:

  1. Unless otherwise stated, template text is untouched
  2. Text within braces ({ and }) is processed as a Calculation on the owning record of the template, and the result of the calculation (expected to be, or converted to, a string of text) is inserted in position in the resulting template output. Note that the simplest ‘calculation’ is just to provide the name of one of the Fields of the owning record – its value will be inserted as the ‘result’ of the calculation.
  3. Special case {NAME} gives the name of the record as displayed in PYXI
  4. Special case {LINK} gives a Link to the record i.e. an anchor link that when clicked takes the user to the page for that record.

Developing and Testing Template Scripts

As a Developer user, you will find a Playpen option at the bottom-left of every record page. This Playpen provides you with a facility to test Template Scripts – these are evaluated against the record ‘on the fly’ and the result shown to you.
The template output itself is presented, and additionally a table is shown with the value of any variables that were sent during the script evaluation. This is also a handy way to test logic built up in other places where scripts are used, such as in View records for Column Views or Funnel Views.


Simple Field Name replacement

The name of this person is {FirstName} {LASTNAME} – email address is {EMAIL}

Note that field names, and calculations in general, are case-insensitive.

Simple Calculation

{if(isUser,FirstName + " is a user.","")}

Evaluated on a Person record, this will display only if that person is a user. The entire template is a single calculation using the if function.