Data Transformer Script task

The Data Transformer Script task lets you write, edit, and evaluate custom Jsonnet templates to perform data mapping in your integration.

For information about the data mapping in Application Integration, see Data mapping overview.

Configure the Data Transformer Script task

To add a Data Transformer Script 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.
    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.
    4. Click Create.

    This opens the integration in the integration editor.

  4. In the integration editor navigation bar, click Tasks to view the list of available tasks.
  5. Click and place the Data Transformer Script element in the integration editor.
  6. Click the Data Transformer Script element on the designer to view the Data Transformer Script task configuration pane.
  7. Click Open Data Transformer Script editor.
  8. The Data Transformer Script editor appears displaying a default commented Jsonnet template example.
  9. Write your Jsonnet code and close the editor once complete. Any changes will be autosaved.

Using the Data Transformer Script editor

You can use the Data Transformer Script editor to access the integration variables, perform variable assignments, and add or modify variables in your integration. The Data Transformer Script editor provides the following features to enrich your scripting experience:

  • Syntax/code highlighting, indentation, and line numbering for easier code readability and structure recognition.
  • A minimap that displays a high-level overview of the script code and helps with quick navigation.
  • Click-to-copy option to copy the script code to the clipboard.

To open the editor, go to the Data Transformer Script task configuration pane and click Open Data Transformer Script Editor.

The Data Transformer Script editor by default imports functions, a predefined custom library containing a set of Jsonnet functions for data mapping in Application Integration. For details of the available custom functions, see Data Transformer functions.

The following image shows the sample layout of the Data Transformer Script editor:

image showing data-transformer script editor image showing data-transformer script editor

Access integration variables

To read an existing integration variable from the Data Transformer Script editor use the extVar function from the predefined functions library.

Example: Read and update existing integration variables using the Data Transformer Script editor.

Jsonnet script

local f = import "functions"; // Import predefined Data Transformer function library

local str1 = f.extVar("inputVar1"); // Access integration input variable "Inputstr1" with value "Hello"
local str2 = f.extVar("inputVar2"); // Access integration input variable "Inputstr2" with value "World"
{
  OutputVar: str1 + " " + str2 + "!", // Write to Jsonnet output variable "OutputVar"
  "output-str-var": str1 + " Integration " + str2 + "!", // Write to Jsonnet output variable "output-str-var"
}

Output

image showing data-transformer script example image showing data-transformer script example

Best practices

For information about the usage limits that apply to the Data Transformer Script task, see Usage limits.

What's next