About Actions with JSON
JavaScript Object Notation (JSON) event handlers allow complex operations to be performed collaboratively between the event handler implementation (in JavaScript) and the application. This is done by having the event handler pass back an array of Actions using JSON.Â
As with all JavaScript code, actions are only performed against records on a mobile device. Swift MEAPâ„¢ cannot run an action or query against the data source database.Â
Before beginning to write any code involving actions, identify the following:Â
- The MODULEID of all modules that are being queried, read, or modified.
- The MEFIELDID of any fields being queried, read, or modified.
For more information about identifying these items, see Obtaining Module ID and Field Name Information.
Each JSON event handler is capable of returning a different set of actions. For more information about the set of actions supported by an event handler, see the related event handler function found further in this section.Â
To code an array of actions, use JSON to return the array of actions. Note that an array must be returned even if there is only one action. As a result, the return value of every JSON event handler will look similar to the following:Â
Â
return "[{ comma separated list of actions }]" |
Â
The return value must always be string encoded.