バージョンを使用してステップを更新、管理する

ステップの新しいバージョンを公開しても、そのステップを含む既存のユーザーフローは自動的に更新されません。ステップを公開した後、以前の動作のサポートを維持するには、変更にバージョンを使用します。

バージョンを使用する必要がある変更は次のとおりです。

  • 新しい必須フィールドを追加する
  • 入力フィールドまたは出力フィールドの非推奨化
  • string、float、int などのデータ型の変更
  • ステップの基本的な動作を変更する

バージョニングを実装するには、ステップのマニフェスト ファイルで current_versionmin_version を指定します。

  • current_version: 現在アクティブなデプロイのバージョン番号。
  • min_version: ステップでサポートされている最も古いバージョン。

次のマニフェストの例は、ステップのバージョンを定義する方法を示しています。

JSON

...
"flows": {
     "workflowElements": [
       {
         "id": "...",
         "state": "...",
         "name": "...",
         "description": "...",
         "version" : {
           "current_version": 3,
           "min_version" : 1
         },
...

実行中に、イベント オブジェクトからバージョン番号を取得し、各バージョンのカスタム動作を定義できます。

Apps Script

/**
 * Executes the step and handles different versions.
 * @param {Object} event The event object from the workflow.
 */
function onExecute(event) {
  // Get the version ID from the execution metadata.
  const versionId = event.workflow.executionMetadata.versionId;

  // Implement different behavior based on the version.
  if (versionId < 2) {
    // Handle earlier versions
  } else {
    // Handle current and newer versions
  }
}