Skip to content

Tokens and placeholders

Reference10 minPractitioner

A token is a marker in a script that Beezr swaps for data before the script runs. This page lists every form, what it becomes, and where it works. For the language itself, read Smart Script: the language of Beezr.

TokenBecomesExample
$table$.$field$A field of a record. table is the module’s table name, such as cm_contracts, or the name of a listparseFloat($cm_contracts$.$contract_value$)
$field$A field of the record on screen$status$
$this$.$user$.$name$The signed-in user’s name. Also $id$ and $email$$this$.$user$.$email$
${name}A variable that a Smart Script fills, in an HTML template<strong>${overdue}</strong>
${label_key}The translation of a label key${info.customers}
${row.propertyValueMap.field}A field of the current row inside a repeated block in an email${(row.propertyValueMap.amount)!}

A list works like a module. Where a module table name goes, write the list’s name: $contract_invoices$.$amount$.

The type of the field decides whether the value is quoted. This is the most common reason a script misbehaves.

Field typeArrives asWhat to do
Text, Text area, LongA quoted string. Quotes and backslashes inside are escapedDo not add quotes of your own
Integer, Decimal, Currency and other non-text typesThe value as it is, no quotesWrap it in parseInt or parseFloat to calculate
DateBare, in Beezr’s standard date textPut quotes round the token, then parse it
LookupThe value the record holds, which is the id. Some records also carry the displayed name, and then you get the nameTest what you get. Compare with the id in a WHERE clause

If the field exists but has no value, a text field arrives as the text 'null' and a number arrives empty.

Integer and Decimal values arrive as they are. Every other type arrives as a quoted string. A field with no value arrives as null, or as the text 'null' for text.

$this$.$user$.$name$, $this$.$user$.$id$ and $this$.$user$.$email$ give the person the script runs for. The value arrives quoted. This is the one token that works in a dashboard metric, where there is no record.

Use a token in a context that supplies its record.

PlaceRecord the tokens readWrite tokens as
Default value, Disabled If, Visible If, form and button parameters, styling rulesThe record on screen only$field$
Rule Book, Custom HTML component, calculated table columns on a formThe record on the form and the form’s module$table$.$field$
Workflow stepsThe record that started the run, the lists you loaded and the current item of a loop$table$.$field$
Dashboard Metric and Custom HTML variablesNo record$this$.$user$... and FunctionManager calls

In workflows and the Rule Book, write the full token even for the record you are working on. The Insert data button in workflow panels writes it that way.

Press Ctrl + Space in a script editor and type $ to see modules, then fields. In workflow panels, Insert data adds only data that exists at that step. Typing @ in a value box opens it too, except in address boxes.

Lists loaded by Load data appear in Insert data under their list name. Name a list after what it holds, such as contract_invoices, and the token reads like a sentence.

Wrap each number in parseInt (whole numbers) or parseFloat, and leave the token without quotes.

parseInt($order_lines$.$qty$) + parseInt($cm_products$.$reserved$)

Join text with + and quote the words you type yourself. Do not quote the token, because text arrives already quoted.

$cm_contracts$.$title$ + ' for ' + $cm_contracts$.$vendor_name$

Never build a number by joining quoted text, as in '$x$' + ' + ' + '$y$'. It gives you text.

${name} is not a Smart Script token. It is a FreeMarker placeholder in an HTML template. Beezr finds each name in the template and gives it a Smart Script. The script’s result replaces the placeholder.

WhereWhat you writeWhere the script goes
Dashboard Custom HTML${overdue} in the HTMLThe Variables tab
Send email${name} in the messageValues, under the message

On dashboards, give each variable a script that returns text.

In an email, a table of rows repeats between <!--#list name as row--> and <!--/#list--> comments, and each cell reads ${(row.propertyValueMap.field)!}. The ! stops a row without that field from failing the whole email.

A label key written as ${info.customers} in a Metric label or a Report title shows the translation for each viewer’s language. Plain text works there as well.

The suggestion list comes from the editor’s helper. Typing FunctionManager. offers the methods, and a module name followed by a dot offers its fields as $field$ tokens. Smart Script functions marks which methods the editor suggests.