Adding JavaScript Code to Modules


You can add JavaScript code to individual modules using the JavaScript icon.


To add JavaScript code to a module

  1. Start the Admin application.
  2. Click Map Settings, and then click Module Settings on the vertical navigation bar. The Module Mapping page opens showing the existing list of mapped modules and the module settings configured for each module. There are a number of icons next to each module, one of which is the JavaScript icon. Click this and choose "Add" in the dialog window.
  3. In the dialog box that opens, enter the following information:
      1. Type. Select the type of code that you want to add from the Type drop-down list. Each type corresponds to a particular context that exposes one or more events. For more information about the type of code that you can add to modules, see the table below.
      2. Expression. Enter the JavaScript code into the Expression box.
  4. Click Save.

 

Note that the event handlers must be the first methods mentioned in the inline JavaScript code in the Expression input box, because the first methods are automatically registered as the event handlers. Any event handlers that are stored in libraries will not be called.

 


The Table below describes the different code types that you can add to modules and the events that are available for each module code type.

Module Code Type

Description

Available Events

onDelete

The onDelete event executes when a user tries to delete a record on a mobile device by selecting delete.

fieldsOnDelete or onDelete
onPostDeleteJSON

onCancel

The onCancel event executes when a user enters a new record on a mobile device, and then selects Cancel.

fieldsOnCancel or onCancel

onCreate

The onCreate event executes when the New or plus icon is selected to, for example, create a new record in the Swift MEAP™ application.

fieldsOnDefault or getDefaultValueOfMEFIELDNAME

onCreateJSON

onOpen

The onOpen event executes when the Quick Selector is selected.

fieldsOnDefault or getDefaultValueOfMEFIELDNAME

onSave

The onSave event executes when Save is selected to save either a new record that is being created or an existing record that is being updated.

fieldsOnPreSave or onPreSave

fieldsOnDefault or getDefaultValueOfMEFIELDNAME
fieldsOnSave or onSave onPreSaveJSON onSaveJSON

onEdit

The onEdit event executes when a user Selects Edit to modify a record.

onEditJSON

CustomActions

The CustomActions event executes when a customized action in the Swift MEAP™ application is selected. Configuring JavaScript code as a custom action adds an icon next to the Edit button in your Swift MEAP™ application. Selecting CustomActions displays a drop-down menu, from which the user can choose an action (or piece of code) to execute.

onActionJSON