Skip to main content
Version: 1.28 (Current)

Execute Javascript Code And Stop Execution

Audience: Low-code Engineers

Skill Prerequisites: Actions, JavaScript, Tokens

Runs JavaScript code in the user's browser and ends execution. No actions after it run. It's available in forms and listings.

The code is the response to the button or event, so it's the last thing that happens. Actions that ran before it aren't undone. In a form, the code can read and change fields through the form object, for example form.fields.TextBox.value.

Typical Use Cases​

  • Finish a button's actions with a client-side effect, such as opening a page in a new tab or printing
  • Show a custom dialog or a browser alert with values from earlier actions, and stop there
  • Stop processing with a condition, and use the code to move the focus to the field that needs attention

Don't use it to​

Action NameDescription
Execute Javascript Code And Continue ExecutionRuns JavaScript in the browser and continues with the next actions.
Stop ExecutionEnds execution without a response.
Execute JavaScript (Server-side)Runs JavaScript on the server.
Display MessageShows a message and ends execution, without writing code.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
Javascript CodeThe JavaScript to run in the browser. Tokens such as [FirstName] are replaced with their values on the server before the code is sent. In a form, fields are also available as form.fields.<FieldName>.value.Yesempty stringNo

How the code runs​

  • Tokens are replaced as plain text. Values aren't escaped for JavaScript. Put tokens inside quotes, for example '[FirstName]'. A value that contains a quote or a line break breaks the code, so read user input from form.fields instead of tokens.
  • The form object is available in forms. form.fields.<FieldName>.value holds the current value of a field. It isn't available in listings.
  • Errors are only logged. The code is wrapped in a try/catch. If it throws, the error is written to the browser console, starting with Execute JsCode Action Error. Execution still ends.

Considerations​

  • Final action. Actions placed after it in the same list never run, unless its condition is false. Use the action's Condition to decide when to stop. See Common Parameters.
  • Scripting license. The action needs the Standard.Scripting feature. If it isn't licensed, the action fails with an error. System pages skip this check.
  • Visible to users. Don't put passwords, keys or other secrets in the code or in the tokens it uses.

Examples​

tip

To understand how to use the below examples, please see Running Examples.

1. Open the generated invoice in a new tab​

This action opens the invoice created by earlier actions in a new browser tab. The [InvoiceUrl] token is placed inside quotes. Nothing runs after it.

{
"Title": "Execute Javascript Code And Stop Execution",
"ActionType": "ExecuteJsCode",
"Description": "Show the invoice",
"Parameters": {
"JavascriptCode": "window.open('[InvoiceUrl]', '_blank');"
}
}

2. Stop and point the user to a missing value​

This action only runs when the Phone field is empty. It shows an alert, moves the focus to the field with the id Phone, and stops the remaining actions.

{
"Title": "Execute Javascript Code And Stop Execution",
"ActionType": "ExecuteJsCode",
"Description": "Ask for a phone number",
"Condition": "[Phone] == \"\"",
"Parameters": {
"JavascriptCode": "alert('Please add a phone number so we can confirm your booking.');\nvar el = document.getElementById('Phone');\nif (el) { el.focus(); }"
}
}

Revised 09/26/2026