Run JavaScript

Extend the capabilities of your SOTI Snap app with custom actions. Use the Run JavaScript action to add custom JavaScript code to your app and define new and complex actions for events.

Run JavaScript actions are added to SOTI Snap apps like any other action: on a widget, add an event and then select Run JavaScript from the Actions dropdown list. Then, you can paste valid, well-formed JavaScript code or edit code directly in the Script Editor.

Tip: Even if you're unfamiliar with JavaScript, you can still create custom actions with Blockly. The visual editor that uses blocks to approximate coding concepts in an easy-to-use manner. For more details, review documentation on how to Run Blockly.

SOTI Snap validates your JavaScript as you type. Click the warning or error messages on the left of the script editor to see the issues. Although SOTI Snap lets you save invalid JavaScript code, the script will not work in the app.

JavaScript APIs

You can augment your custom JavaScript actions by embedding SOTI Snap objects and functions directly within your scripts. While in the JavaScript text editor, type Snap. (capital 'S', period included) and then hold down Control + Space to trigger a list of SOTI Snap APIs.

JavaScript with SOTI Snap API
Note: Read the API reference documentation at SOTI Snap JavaScript APIS. Note that features and syntax introduced in ECMAScript 2015 (ES6) are not supported.

You can also use native JavaScript DOM APIs or jQuery-based APIs to interact with SOTI Snap widgets, but we recommend using SOTI Snap JavaScript APIs wherever possible.