Configuring JavaScript Code

The use of JavaScript is beyond the scope of this manual, but the ability to add JavaScript functionality to modules greatly increases the ability to customize the application. You could, for instance, create JavaScript code to force users to enter a planned call record whenever an opportunity record has been created to ensure callbacks are made. It can also be used to mimic validation rules that are in place on the server for data entry.

JavaScript can be set up to be run:

  • onDelete: Whenever a device record within a module is being deleted.
  • onCancel: Whenever the cancel button is pressed within the record creation form.
  • onOpen: Whenever a device record is opened.
  • onCreate: Whenever a new record is being created on the device.
  • onSave: Whenever a device record is saved within the module.
  • onEdit: Whenever a device record is placed in Edit mode.


In addition, JavaScript can be assigned to a custom action button. This would enable users to select when the JavaScript code is executed by clicking on the action button. Multiple sets of code can be configured, when a user clicks on the action button on the tablet, they will be presented with a list of scripts where the relevant action can be executed.
To use the custom action button, click on CustomActions to execute the code using the custom actions button.

To configure JavaScript code:

  1. Click on the JavaScript icon next to the module you wish to configure code for in the Map Settings → Module Settings menu. If no icon is displayed, see JavaScript Icon.
  2. The Module JavaScript Function window will appear showing all current JavaScript entries for events. Click 'Add'.
  3. Choose when you would like the code to be executed by using the Type drop down selection box.
  4. If you have selected CustomActions, you will need to enter a display value. This will be used on the iPad to identify the action being performed.
  5. Add the JSON or JavaScript to the Expressions box.
  6. Click Save to complete or Cancel to exit without making changes.

 

Only one script may be entered per event. For Example, only one 'onEdit' event code may exist for the Contacts Module. That code, however, may cover a number of different conditions and fields.