Tokens and placeholders
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.
Which token forms exist?
Section titled “Which token forms exist?”| Token | Becomes | Example |
|---|---|---|
$table$.$field$ | A field of a record. table is the module’s table name, such as cm_contracts, or the name of a list | parseFloat($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$.
How does a value arrive?
Section titled “How does a value arrive?”The type of the field decides whether the value is quoted. This is the most common reason a script misbehaves.
The full token, $table$.$field$
Section titled “The full token, $table$.$field$”| Field type | Arrives as | What to do |
|---|---|---|
| Text, Text area, Long | A quoted string. Quotes and backslashes inside are escaped | Do not add quotes of your own |
| Integer, Decimal, Currency and other non-text types | The value as it is, no quotes | Wrap it in parseInt or parseFloat to calculate |
| Date | Bare, in Beezr’s standard date text | Put quotes round the token, then parse it |
| Lookup | The value the record holds, which is the id. Some records also carry the displayed name, and then you get the name | Test 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.
The bare token, $field$
Section titled “The bare token, $field$”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.
The user token
Section titled “The user token”$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.
Which places pass which data?
Section titled “Which places pass which data?”Use a token in a context that supplies its record.
| Place | Record the tokens read | Write tokens as |
|---|---|---|
| Default value, Disabled If, Visible If, form and button parameters, styling rules | The record on screen only | $field$ |
| Rule Book, Custom HTML component, calculated table columns on a form | The record on the form and the form’s module | $table$.$field$ |
| Workflow steps | The record that started the run, the lists you loaded and the current item of a loop | $table$.$field$ |
| Dashboard Metric and Custom HTML variables | No 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.
How do I write a calculation or a join?
Section titled “How do I write a calculation or a join?”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.
What are the ${...} variables?
Section titled “What are the ${...} variables?”${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.
| Where | What you write | Where the script goes |
|---|---|---|
| Dashboard Custom HTML | ${overdue} in the HTML | The Variables tab |
| Send email | ${name} in the message | Values, 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.
What do the editors suggest?
Section titled “What do the editors suggest?”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.