Page tree
Skip to end of metadata
Go to start of metadata

It is possible to perform actions within a message when an event occurs. These include performing a calulation, capturing location etc. To configure see the 'Actions' section under the 'Extras' tab in a Template.


Available events include:

on change in valuewhen a field's value is changed, eg entering text
on navigationchanging tabs or going to another card via a Link Command
after loading remote datatriggered when a remote load has successfully completed
after a message is createdtriggered when a new message is created after default data has been set
after a message is replied totriggered when a message is replied to after the data has been copied from the original message


Available actions include:

Call JavaScript functioncalls the named JavaScript function
Capture locationattempts to get the current location and stores in the selected meta data
Reset default valueresets the selected fields to their defaults


An example of a JavaScript function being called after a change in the start or finish time (both are Date Item fields).


JavaScript Actions

It is possible to run JavaScript functions to perform calculations on the device and other roles such as more advanced validation and workflow decisions.

The functions should take a single argument that will be a JS object derived from the message data at the level the function is run. For example if the function is run at the root level then it will be all the message data. If the function is run within a list card item then it will only contain that items data. It should return a JS object with a data property that contains the values to be merged back into the current message data.

There are options for running JS function when the 'done' button is pressed to exit editing a list card item and to perform extra validation when sending a message or exiting a list card item. You may use this to set a complete flag for the item, as well as performing more complex validation, for example.

Set the content of the JS Functions text area, under the 'Extras' tab, with the content of the JS to compile. This can include supporting variables and functions along with the actual function to call from AMS.

When accessing JS values the property is set to the external label. For example a Date Item with external label start would be accessed in the JS function like msgData.start (assuming that 'msgData' is the name of the single argument in the function definition). The following are the data types for the values:

FieldJS Data Type
Text, String or Text BoxString
DateJS Date
Choice GroupArray of Strings
ListJS Object with values of selected list item as properties
List CardArray of JS Objects (each object is a list card entry)
Meta DataString



As numbers (decimals etc) are entered in Text Fields they will be represented in JS as String values. So you will need to convert them to JS numbers in order to use then in calcuations.



An example of a simple time calculation:

Simple Timesheet Calc


An example of calculating a score based on answers to questions:


Sample JS Calc



  • No labels