MAX Variable Reference - Developer Site

Object Full variable name Description
request
{request.[param]} the value of the parameter named [param] in the current url. If param is not found, contains an empty string
{request.querystring} a string containing the query part of the current url, i.e the string after the ?
query
{[queryid].[field]} the value of the field named [field] for the current record of the query identified by its id attribute [queryid]
{[queryid].count} the number of records in the query identified by its id attribute [queryid]
{query.lastrowid} the primary key value of the last inserted record in a local datastore, after a call to query.execute() script function
{query.groupcount([value])} the number of records in the query for which the groupcount field has a value equal to [value].
The groupcount field name must be set in the groupcount attribute in the <query> tag.
item
{this.text}, {selection.text} or {[itemid].text} the text content of the current or selected <item> element
{this.id}, {selection.id} or {[itemid].id} the value of the id attribute of the current or selected <item> element
{this.icon}, {selection.icon} or {[itemid].icon} the value of the icon attribute of the current or selected <item> element
page 
{page.title} the title of the current <page>
{page.id} the id of the current <page>
{page.url} the url of the curret <page>
{page.selectedlink} the href value of the currently selected hyperlink in the <textarea> element of the current <page>
device
{device.now} the current date and time as a long integer (in Epoch format, number of milliseconds since Jan 1st, 1970)
{device.version} the version of the Upvise client currently installed on the phone

How variables work and where can I use them?

Variables are always enclosed inside brackets {}. You can use variables anywhere in the attributes and text content of any XML element of the MAX language except in the following cases

When are variables resolved?

are evaluated during page load and replaced by their value, before the page is displayed on the phone screen. Exceptions are {this.xxx} and {selection.xxx} and {document.selectedlink} varaibles, found inside a onclick attribute of an <item> or <textarea> element,  which are resolved only when the script is executed.

Variable Operators

A limited but useful set of operators can be used inside  brackets:

  • conditional operator  a ? b : c
  • equality operator  a == b
  • different operator  a != b
  • superior operator a> b 
  • inferior operator a < b 
  • logical AND operator a && b
  • logical OR operator a || b

These operators can use any above variable as parameter and also literals such a number and string to be put inside single quotes.

Variable Modifiers

A variable is always in the format objectname.variablename. You can add an optional suffix modifier after the variable name  in the following syntax: objectname.variablename.modifier . These Modifiers are used to modify the value of the variable value.

The valid modifiers are :

  • lowercase : puts the variable value to lower case. Requires that the type of the variable is a string.
  • formatdate : transform the long integer value of the varaible to a formated string containing the short date in the format DD,MM,YY

Literals

Integer and String literals can be used. String literals must be enclosed with simple quotes, for example: 'hello'.