JavaScript task
Deprecated: Effective January 24, 2025, Application Integration will no longer support Rhino as the JavaScript execution engine. All existing publishedJavaScript tasks will continue to use Rhino and can bemigrated to V8 manually. Newly createdJavaScript tasks will exclusively use V8. SeeJavaScript execution engine for more information.The JavaScript task lets you write custom JavaScript code snippets for your integration.
Using theJavaScript Editor, you can code complex data mapping logic for your integration, perform variable assignments, and add or modify integration variables.
TheJavaScript Editor supports the following features:
- A minimap that displays a high-level overview of the script code and helps with quick navigation.
- Syntax/code highlighting, indentation, and line numbering for easier code readability and structure recognition.
- Error highlighting to find and track errors in code.
- Folding to expand and collapse regions of the script code.
- Click-to-copy option to copy the script code to the clipboard.
Configure the JavaScript task
To add a JavaScript task to your integration, perform the following steps:
- In the Google Cloud console, go to theApplication Integration page.
- In the navigation menu, clickIntegrations.
TheIntegrations page appears listing all the integrations available in the Google Cloud project.
- Select an existing integration or clickCreate integration to create a new one.
If you are creating a new integration:
- Enter a name and description in theCreate Integration pane.
- Select a region for the integration.Note: TheRegions dropdown only lists the regions provisioned in your Google Cloud project. To provision a new region, clickEnable Region. SeeEnable new region for more information.
- Select a service account for the integration. You can change or update the service account details of an integration any time from theIntegration summary pane in the integration toolbar.Note: The option to select a service account is displayed only if you have enabled integration governance for the selected region.
- ClickCreate. The newly created integration opens in theintegration editor.
- In theintegration editor navigation bar, clickTasks to view the list of available tasks and connectors.
- Click and place theJavaScript element in the integration editor.
- Click theJavaScript element on the designer to view theJavaScript task configuration pane.
- ClickOpen script editor to view and edit theJavaScript Editor. You can also use Gemini to generate JavaScript code by clickScript with Gemini. For information about using Gemini to generate JavaScript code, seeConfigureJavaScript tasks with Gemini assistance.
- Write your JavaScript code inside the
executesScript(event)function that is automatically created in theJavaScript Editor. Close the editor once complete, any changes will be autosaved.Warning: Don't delete theexecutesScript(event)function. This function is called when theJavaScript task executes.For information about accessing integration variables and the supported functions, see Using the JavaScript Editor.
For information about viewing the generated execution logs, seeExecution logs.
The following image shows a sample layout of theJavaScript Editor:

Use the JavaScript Editor
To view and edit theJavaScript Editor, go to theJavaScript task configuration pane and clickOpen script editor. TheJavaScript Editor by default contains a function namedexecutesScript(event), where:
executesScript(): the function that is called when Application Integration executes theJavaScript task during an integration's run.event: thein-memory object of Application Integration.For information about the supported methods of theevent object, see Access integration variables.
executesScript(event) function. This function is called when theJavaScript task executes.JavaScript execution engine
Deprecated: Effective January 24, 2025, Application Integration will no longer support Rhino as the JavaScript execution engine. All existing publishedJavaScript tasks will continue to use Rhino and can bemigrated to V8 manually. Newly createdJavaScript tasks will exclusively use V8.Application Integration previously supported Rhino as the JavaScript execution engine for runningJavaScript tasks. To leverage the performance and security benefits of Google's open-source high-performance JavaScript engine, Rhino will be deprecated and all JavaScript executions will now utilize V8, Google's open-source high-performance JavaScript engine.
Benefits of V8
The V8 JavaScript engine offers the following benefits:
- Performance: V8 is significantly faster than Rhino, leading to improved execution speeds for yourJavaScript tasks. Scripts with large sized variables and complex computations can be executed faster.
- Standards Compliance: V8 supports ECMAScript 2024, ensuring better compatibility and maintainability.
- Security: V8 benefits from ongoing security updates and improvements, providing a more secure environment for your integrations.
- Modern Features: V8 supports the latest JavaScript features, allowing you to leverage modern language constructs and libraries.
Migrate existing JavaScript tasks to V8
To migrate your existingJavaScript tasks running on Rhino to V8, do the following:
- Identify the published integrations that containJavaScript tasks and unpublish them.
- For eachJavaScript, clickOpen script editor from the task configuration pane.
Application Integration automatically updates the existing script to use V8.
- Review and test the JavaScript code.
- Publish the integrations.
Access integration variables
Variables defined in your integration can be accessed from theJavaScript Editor using the Application Integration in-memoryevent object.
The following methods are supported to access integration variables from yourJavaScript Editor:
| Function name | Description | Usage | |
|---|---|---|---|
| Returns the integration's run execution ID. Return type: String | Syntax: Example: functionexecuteScript(event){event.getEventExecutionInfoId();} | |
| Returns the Google Cloud project ID. Return type: String | Syntax: Example: functionexecuteScript(event){event.getGcpProjectId();} | |
| Returns the current name of the integration. Return type: String | Syntax: Example: functionexecuteScript(event){event.getIntegrationName();} | |
| Returns the value of the provided integration variable. Return type: Data type of the integration variable | Syntax: Input parameter: Integration variable name. If the Example: functionexecuteScript(event){event.getParameter("var1");} | |
| Returns the name of the integration region. Return type: String | Syntax: Example: functionexecuteScript(event){event.getRegion();} | |
| Writes the specified value to the execution logs. For information about viewing the generated execution logs, seeExecution logs. | Syntax: Input parameter: Any variable or function that is used in the script. Example 1: functionexecuteScript(event){event.log(event.getParameter("var1"));} Example 2: functionexecuteScript(event){event.log("Lorem ipsum");} | |
| Sets or updates the value of an integration variable. | Syntax: Input parameter: This function takes the following arguments:
Example: functionexecuteScript(event){event.setParameter("`responseBody`","NewStringValue");} | |
Set task parameters
If your integration has multiple large sized parameters that are not used by the JavaScript task, you can set theTaskParameter field for the JavaScript task to improve performance.
To set theTaskParameter field for the JavaScript task, select one of the following options:
Console
- Go to theApplication Integration page.
- Select an integration. The integration editor opens.
- ClickAction>Download Integration>Integration Version. The integration version is downloaded as a JSON file.
- Open the integration version file in an editor, and then do the following:
- Locate the
taskConfigsfield with the task asJavaScriptTask. In theparametersfield, locate the parameter namedscript."taskConfigs": [{ "task": "JavaScriptTask", "taskId": 1, "parameters": { "script": { "key": "script", "value": { "stringValue": "function that is called during the JavaScriptTask execution" } }"}] - In this
parametersfield, add parameters that are used in theJavaScriptTaskfield by using the following template:"ParamName": { "key": "ParamName", "value": { "stringValue": "$ParamName$" }}
- Locate the
- Save the changes that you made to the integration version file.
- Upload the integration version file to the integration.
API
- To download the integration version, make a call to the
projects.locations.integrations.versions.downloadmethod with thefilFormatset toJSON. - Open the integration version file in an editor, and then do the following:
- Locate the
taskConfigsfield with the task asJavaScriptTask. In theparametersfield, locate the parameter namedscript."taskConfigs": [{ "task": "JavaScriptTask", "taskId": 1, "parameters": { "script": { "key": "script", "value": { "stringValue": "function that is called during the JavaScriptTask execution" } }"}] - In this
parametersfield, add parameters that are used in theJavaScriptTaskfield by using the following template:"ParamName": { "key": "ParamName", "value": { "stringValue": "$ParamName$" }}
- Locate the
- To upload the integration version, make a call to the
projects.locations.integrations.versions.uploadmethod with the updated integration version file.
Error handling strategy
An error handling strategy for a task specifies the action to take if the task fails due to atemporary error. For information about how to use an error handling strategy, and to know about the different types of error handling strategies, seeError handling strategies.
Quotas and limits
For information about quotas and limits, seeQuotas and limits.
What's next
- Learn about the following:
- Testing and publishing integrations
- Error handling
- Integration execution logs
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.