See the supported connectors for Application Integration.
Update JSON array at a specified index
Using the Data Mapping task, update the value of a JSON array at a specified index using an input variable. Store the output in a new JSON variable.
Code sample
{
"triggerConfigs": [{
"label": "API Trigger",
"startTasks": [{
"taskId": "1"
}],
"properties": {
"Trigger name": "tkApplicationIntegrationSample1_API_1"
},
"triggerType": "API",
"triggerNumber": "1",
"triggerId": "api_trigger/tkApplicationIntegrationSample1_API_1"
}],
"taskConfigs": [{
"task": "FieldMappingTask",
"taskId": "1",
"parameters": {
"FieldMappingConfigTaskParameterKey": {
"key": "FieldMappingConfigTaskParameterKey",
"value": {
"jsonValue": "{\n \"@type\": \"type.googleapis.com/enterprise.crm.eventbus.proto.FieldMappingConfig\",\n \"mappedFields\": [{\n \"inputField\": {\n \"fieldType\": \"JSON_VALUE\",\n \"transformExpression\": {\n \"initialValue\": {\n \"referenceValue\": \"$jsonArray$\"\n },\n \"transformationFunctions\": [{\n \"functionType\": {\n \"jsonFunction\": {\n \"functionName\": \"TO_STRING_ARRAY\"\n }\n }\n }, {\n \"functionType\": {\n \"stringArrayFunction\": {\n \"functionName\": \"SET\"\n }\n },\n \"parameters\": [{\n \"initialValue\": {\n \"literalValue\": {\n \"intValue\": \"2\"\n }\n }\n }, {\n \"initialValue\": {\n \"referenceValue\": \"$jsonVar$\"\n },\n \"transformationFunctions\": [{\n \"functionType\": {\n \"jsonFunction\": {\n \"functionName\": \"TO_STRING\"\n }\n }\n }]\n }]\n }, {\n \"functionType\": {\n \"stringArrayFunction\": {\n \"functionName\": \"TO_JSON\"\n }\n }\n }]\n }\n },\n \"outputField\": {\n \"referenceKey\": \"$outputJsonArray$\",\n \"fieldType\": \"JSON_VALUE\",\n \"cardinality\": \"OPTIONAL\"\n }\n }]\n}"
}
}
},
"taskExecutionStrategy": "WHEN_ALL_SUCCEED",
"displayName": "Data Mapping"
}],
"integrationParameters": [{
"key": "outputJsonArray",
"dataType": "JSON_VALUE",
"displayName": "outputJsonArray",
"inputOutputType": "OUT",
"jsonSchema": "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"prop1\": {\n \"type\": \"string\"\n }\n }\n }\n}"
}, {
"key": "jsonArray",
"dataType": "JSON_VALUE",
"defaultValue": {
"jsonValue": "[{\n \"prop1\": \"val11\"\n}, {\n \"prop1\": \"val21\"\n}, {\n \"prop1\": \"val31\"\n}, {\n \"prop1\": \"val41\"\n}]"
},
"displayName": "jsonArray",
"jsonSchema": "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"prop1\": {\n \"type\": \"string\"\n }\n }\n }\n}"
}, {
"key": "jsonVar",
"dataType": "JSON_VALUE",
"defaultValue": {
"jsonValue": "{\n \"prop1\": \"valUserDefined\"\n}"
},
"displayName": "jsonVar",
"jsonSchema": "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n \"type\": \"object\",\n \"properties\": {\n \"prop1\": {\n \"type\": \"string\"\n }\n }\n}"
}]
}
Sample integration flow
The following image shows a sample layout of the integration editor for this integration code sample.
Upload and run the sample integration
To upload and run the sample integration, do the following steps:
Save the integration sample as a .json file on your system.
In the Google Cloud console, go to the Application Integration page.
Go to Application Integration
In the navigation menu, click Integrations . The Integrations page appears.
Select an existing integration or create a new integration by clicking Create integration .
If you are creating a new integration:
Enter a name and description in the Create Integration dialog.
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.
Select a service account for the integration. You can change or update the service account details of an integration any time from the info 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.
Click Create .
This opens the integration in the integration editor .
In the integration editor , click publish Upload/download menu and then select Upload integration .
In the file browser dialog, select the file that you saved in step 1, and then click Open .
A new version of the integration is created using the uploaded file.
In the integration editor , click Test .
Click Test integration . This runs the integration and displays the execution result in the Test Integration pane.