Skip to end of metadata
Go to start of metadata

Allows you to complement the functionality of the platform using JS or HTML code.

This lesson explains features of the element and gives an example of using JS for Web Share API in the app.

Use cases:

You can use JS code to interact/change/modify/update all of platform’s entities, like screen elements, like data points. Use it to achieve ANY result needed for your application. 

You can also use it for:

  • calling Web APIs, for direct access to hardware
  • embedding games or special visual behaviour
  • connecting any JS libraries, for example for charts
  • etc 

How to Use Custom JS/HTML


The HTML or JavaScript Element is marked RED, and code inputs, marked ORANGE, located in Properties of the element Custom JS/HTML. 

Note: you can expand this area for easier editing with two arrows (GREEN mark)

EXAMPLE  - Link sharing using Web API.

How it works in the app:

  • User inputs a link,
  • clicks Share button,
  • chooses an application to share it to. 

This is the code, you can copy/paste it for own tests:

const share = function(){
    title: '',
    text: 'look at this: ' +"Backendname:text_input_share_link").properties.value,
    .then(() => console.log('Successful share'))
    .catch((error) => console.log('Error sharing', error));
if (navigator.share) {
MBST.addActionListener("button_share_link", share)


Referencing data points using Hashtags:

You can use all data points on the Mobsted platform in your Custom JS. One of the ways to get the value of "text_input_share_link" element is our standard #hashtag# function.

Just change #name# for “name” in JS. Other functions to get the value are described at the end of this lesson. command is the enactor to the hashtag function. A hashtag can reference:

  • element on this screen"Backendname:name")
  • object"Object:InviteUrl"
  • app"Application:Name")
  • variable in a session"Variable:Task_ID")
  • filter"EventsFilter:Name_Filter:Data")
  • etc 

Listener for actions

You can set JS to communicate to elements placed on screen using backend names given:

MBST.****** command allows this.

In our example: MBST.addActionListener("button_share_link", share) - tracks the click on the button called "button_share_link" and calls the share function. 

Code usage features:

The code specified in the `Javascript code` field will be executed in strict mode (ES5 "use strict").

A JavaScript object is available for interaction with the Platform:

MBST = {

platform: (string) 'ios|android',

ht: function (path[, value]),

watch: function (path, callback),

addActionListener: function(name, callback),

component: function (name),

action: function ([index], [actionsList])



Again, at the constructor you use notation #Variable:test#, but in JS:"Variable:test")

`MBST.platform` - the 'ios' or 'android' string indicates the type of device the application is running on.

`[, value])` - platform hashtag read/write function. 

  • Read - `"Variable:test")`. 
  • Write - `"Variable:test", "new value")`. 

`, callback)` - tracks changes in a hashtag. The new hashtag value is passed to callback

For example, `"Backendname:text-field", (value) => console.log(value));`.

`MBST.addActionListener(name, callback)` - assigning an event handler of the component on the current app screen, i.e. “button press”.  

For example, `MBST.addActionListener("button_share_link", share)`.

`MBST.component(name)` - function to return available component parameters. Available parameters can be viewed using `console.log(MBST.component("button-test"))`

`MBST.action([index], [actionsList])` - function that performs a component actions.

  • index - determines the sequence number of the action to be performed. If no number is set, all actions are performed.
  • actionsList - defines a list of actions. If not, the list of actions of component 'Custom JS/HTML' itself is used.

NOTE - To perform actions of a component of the current screen, you need to pass them using the second parameter - “actionsList”. The list of available actions for each component can be obtained by `MBST.component("button-test").actions`