Application Integration でサポートされているコネクタをご覧ください。

指定したインデックスの JSON 配列を更新する

データ マッピング タスクを使用して、入力変数を使用して、指定されたインデックスの JSON 配列の値を更新します。出力を新しい JSON 変数に格納します。

コードサンプル

{
  "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}"
  }]
}

統合フローのサンプル

次の図は、この統合コードサンプルの統合エディタのサンプル レイアウトを示しています。

統合フローのサンプルを示す画像 統合フローのサンプルを示す画像

サンプル統合をアップロードして実行する

サンプル統合をアップロードして実行するには、次の手順に従います。

  1. 統合サンプルを .json ファイルとしてシステムに保存します。
  2. Google Cloud コンソールで [Application Integration] ページに移動します。

    Application Integration に移動

  3. ナビゲーション メニューで [統合] をクリックします。[統合リスト] ページが表示されます。
  4. 既存の統合を選択するか、[統合を作成] をクリックして新しい統合を作成します。

    新しい統合を作成する場合:

    1. [統合の作成] ダイアログで名前と説明を入力します。
    2. 統合のリージョンを選択します。
    3. 統合用のサービス アカウントを選択します。統合のサービス アカウントの詳細は、統合ツールバーの [統合の概要] ペインでいつでも変更または更新できます。
    4. [作成] をクリックします。

    統合エディタで統合が開きます。

  5. 統合エディタで、 [アップロード / ダウンロード メニュー] をクリックし、[統合をアップロード] を選択します。
  6. ファイル ブラウザ ダイアログで、ステップ 1 で保存したファイルを選択し、[開く] をクリックします。

    統合の新しいバージョンは、アップロードされたファイルを使用して作成されます。

  7. 統合エディタで [テスト] をクリックします。
  8. [テスト統合] をクリックします。統合が実行され、[テスト統合] ペインに実行結果が表示されます。