[ Web Proxy ]
URL:
Viewing: https://docs.cloud.google.com/application-integration/docs/configure-javascript-task [Back]  [Original]

JavaScript task  |  Application Integration  |  Google Cloud Documentation Skip to main content
Google Cloud Documentation [Google Cloud Documentation]
Send feedback Stay organized with collections Save and categorize content based on your preferences.

JavaScript task

Deprecated: Effective January 24, 2025, Application Integration will no longer support Rhino as the JavaScript execution engine. All existing published JavaScript tasks will continue to use Rhino and can be migrated to V8 manually. Newly created JavaScript tasks will exclusively use V8. See JavaScript execution engine for more information.

The JavaScript task lets you write custom JavaScript code snippets for your integration.

Using the JavaScript Editor, you can code complex data mapping logic for your integration, perform variable assignments, and add or modify integration variables.

The JavaScript Editor supports the following features:

Configure the JavaScript task

To add a JavaScript task to your integration, perform the following steps:

  1. In the Google Cloud console, go to the Application Integration page.

    Go to Application Integration

  2. In the navigation menu, click Integrations.

    The Integrations page appears listing all the integrations available in the Google Cloud project.

  3. Select an existing integration or click Create integration to create a new one.

    If you are creating a new integration:

    1. Enter a name and description in the Create Integration pane.
    2. Select a region for the integration. Note: The Regions dropdown only lists the regions provisioned in your Google Cloud project. To provision a new region, click Enable Region. See Enable new region for more information.
    3. Select a service account for the integration. You can change or update the service account details of an integration any time from the Integration 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.
    4. Click Create. The newly created integration opens in the integration editor.

  4. In the integration editor navigation bar, click Tasks to view the list of available tasks and connectors.
  5. Click and place the JavaScript element in the integration editor.
  6. Click the JavaScript element on the designer to view the JavaScript task configuration pane.
  7. Click Open script editor to view and edit the JavaScript Editor. You can also use Gemini to generate JavaScript code by click Script with Gemini. For information about using Gemini to generate JavaScript code, see Configure JavaScript tasks with Gemini assistance.
  8. Write your JavaScript code inside the executesScript(event) function that is automatically created in the JavaScript Editor. Close the editor once complete, any changes will be autosaved. Warning: Don't delete the executesScript(event) function. This function is called when the JavaScript 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, see Execution logs.

The following image shows a sample layout of the JavaScript Editor: image showing javascript editor [image showing javascript editor] image showing javascript editor [image showing javascript editor]

Use the JavaScript Editor

To view and edit the JavaScript Editor, go to the JavaScript task configuration pane and click Open script editor. The JavaScript Editor by default contains a function named executesScript(event), where:

Warning: Don't delete the executesScript(event) function. This function is called when the JavaScript task executes.

JavaScript execution engine

Deprecated: Effective January 24, 2025, Application Integration will no longer support Rhino as the JavaScript execution engine. All existing published JavaScript tasks will continue to use Rhino and can be migrated to V8 manually. Newly created JavaScript tasks will exclusively use V8.

Application Integration previously supported Rhino as the JavaScript execution engine for running JavaScript 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:

Migrate existing JavaScript tasks to V8

To migrate your existing JavaScript tasks running on Rhino to V8, do the following:

  1. Identify the published integrations that contain JavaScript tasks and unpublish them.
  2. For each JavaScript, click Open script editor from the task configuration pane.

    Application Integration automatically updates the existing script to use V8.

  3. Review and test the JavaScript code.
  4. Publish the integrations.

Access integration variables

Variables defined in your integration can be accessed from the JavaScript Editor using the Application Integration in-memory event object.

The following methods are supported to access integration variables from your JavaScript Editor:
Function name Description Usage

getEventExecutionInfoId

Returns the integration's run execution ID.

Return type: String

Syntax: event.getEventExecutionInfoId()

Example:

function executeScript(event) {
  event.getEventExecutionInfoId();
  }
      

getGoogleCloudProjectId

Returns the Google Cloud project ID.

Return type: String

Syntax: event.getGoogleCloudProjectId()

Example:

function executeScript(event) {
  event.getGcpProjectId();
  }

getIntegrationName

Returns the current name of the integration.

Return type: String

Syntax: event.getIntegrationName

Example:

function executeScript(event) {
  event.getIntegrationName();
  }

getParameter

Returns the value of the provided integration variable.

Return type: Data type of the integration variable

Syntax: event.getParameter("variable_name")

Input parameter: Integration variable name. If the variable_name is an auto-generated variable, then enclose the variable in backticks (``). For example, `responseBody`.

Example:

function executeScript(event) { 
  event.getParameter("var1");
  }

getRegion

Returns the name of the integration region.

Return type: String

Syntax: event.getRegion()

Example:

function executeScript(event) {
  event.getRegion();
  }

log

Writes the specified value to the execution logs.

For information about viewing the generated execution logs, see Execution logs.

Syntax: event.log(value)

Input parameter: Any variable or function that is used in the script.

Example 1:

function executeScript(event) {
  event.log(event.getParameter("var1"));
  }

Example 2:

function executeScript(event) {
  event.log("Lorem ipsum");
  }

setParameter

Sets or updates the value of an integration variable.

Syntax: event.setParameter("variable_name", "variable_value")

Input parameter: This function takes the following arguments:

  • First argument: Variable name. If the variable_name is an auto-generated variable, then enclose the variable in backticks (``). For example, `responseBody`.
  • Second argument: Value.

Example:

function executeScript(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 the TaskParameter field for the JavaScript task to improve performance.

To set the TaskParameter field for the JavaScript task, select one of the following options:

Console

  1. Go to the Application Integration page.

    Go to Application Integration

  2. Select an integration. The integration editor opens.
  3. Click Action > Download Integration > Integration Version. The integration version is downloaded as a JSON file.
  4. Open the integration version file in an editor, and then do the following:
    1. Locate the taskConfigs field with the task as JavaScriptTask. In the parameters field, locate the parameter named script.
      "taskConfigs": [{
        "task": "JavaScriptTask",
        "taskId": 1,
        "parameters": {
          "script": {
            "key": "script",
            "value": {
              "stringValue": "function that is called during the JavaScriptTask execution"
            }
        }"
      }]
      
    2. In this parameters field, add parameters that are used in the JavaScriptTask field by using the following template:
      "ParamName": {
        "key": "ParamName",
        "value": {
          "stringValue": "$ParamName$"
        }
      }
      
  5. Save the changes that you made to the integration version file.
  6. Upload the integration version file to the integration.

API

  1. To download the integration version, make a call to the projects.locations.integrations.versions.download method with the filFormat set to JSON.
  2. Open the integration version file in an editor, and then do the following:
    1. Locate the taskConfigs field with the task as JavaScriptTask. In the parameters field, locate the parameter named script.
      "taskConfigs": [{
        "task": "JavaScriptTask",
        "taskId": 1,
        "parameters": {
          "script": {
            "key": "script",
            "value": {
              "stringValue": "function that is called during the JavaScriptTask execution"
            }
        }"
      }]
      
    2. In this parameters field, add parameters that are used in the JavaScriptTask field by using the following template:
      "ParamName": {
        "key": "ParamName",
        "value": {
          "stringValue": "$ParamName$"
        }
      }
      
  3. To upload the integration version, make a call to the projects.locations.integrations.versions.upload method 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 a temporary error. For information about how to use an error handling strategy, and to know about the different types of error handling strategies, see Error handling strategies.

Quotas and limits

For information about quotas and limits, see Quotas and limits.

What's next

Send feedback

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-08-11 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-11 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page