Skip to content

Execute JavaScript – calling a function in the browser of the user

The command "Execute JavaScript" calls a JavaScript function in the browser of the user and can take its return value. This page is for administrators who extend the user interface with their own scripts.


1. At a glance

Purpose Call a JavaScript function that is loaded in the application
Typical use Hand data to a browser integration (for example a telephony client); read a value from the browser
Where in the editor Toolbar menu "UI" → "Execute JavaScript"
Needs a user interface Yes
Related Global settings – "Global Scripts"

The command only calls functions that already exist in the browser – built-in browser functions or functions loaded with "Global Scripts" in the global settings or the scripts of a role. It does not run code entered in the command.


2. Settings

"Display Name", "Description" and "Execution Condition" are on the tab "General" (see Actions).

Tab "General"

Setting Meaning Default / Required
"Function Name" Expression for the name of the function, looked up from the global window object, for example alert or myCompany.phone.dial Required
"Return Value Variable" The variable the return value is written into Optional

Tab "Set Parameters"

The plus button adds a parameter. The parameters are passed in this order.

Setting Meaning
"Value" Expression for the value of the parameter. Empty passes null.
"Data Type" The type the value is converted to before it is passed: "Text", "Double", "Integer", "Date", "Date & Time", "Boolean" or "Guid". Empty: text.

3. Behaviour

  1. Without a user interface – for example in a scheduled action or a background rule – the command is skipped.
  2. The function name and the parameters are evaluated.
  3. The function is called in the browser of the user who runs the action. If it returns a promise, nexxcite waits for it.
  4. The return value is written into "Return Value Variable".
  5. If the function does not exist or throws an error, the reason is written to the log and the action continues; the variable keeps its previous value.

4. Examples

Dial a phone number with a softphone integration. A global script defines window.acmePhone.dial(number).

  • "Function Name" acmePhone.dial
  • Parameter: "Value" = the phone field of the contact, "Data Type" Text

Ask the browser for its time zone. A global script defines window.nxTools.timeZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone. "Function Name" nxTools.timeZone, "Return Value Variable" BrowserTimeZone.


5. Limitations

  • Needs a user interface.
  • No error variable; failures are only visible in the log.
  • In our assessment, a function that takes longer than about one minute to return is abandoned by the connection between browser and server.
  • Scripts run with the rights of the signed-in user in the browser. Only load scripts whose content and origin you know (see Global settings).