コメントタイプのスクリプトコードと入力アクションの更新

  • リリースバージョン: Yokohama
  • 更新日 2025年03月06日
  • 所要時間:2分
  • 次のスクリプトを使用して、入力フォームに入力されたユーザーコメントの保存場所を決定します。このスクリプトは、コメントの削除、更新、新しいテキストの挿入、変更のタイムスタンプの追跡も記録します。

    このコードは、特定の入力のパラメーター アクションを処理する関数 WriteBackAction を定義します。input1 のパラメーターアクションを取得し、それらを反復処理してコメントを処理します。コメントが削除済みとしてマークされている場合、アドミニストレーターはコメントの削除を処理するロジックを設定できます。対応するフィールドを空の文字列に設定する場合。それ以外の場合は、コメント値と最後に更新されたタイムスタンプを取得して、特定のレコードの結果テーブルにコメントを追加または更新します。

    (function WriteBackAction(parm_input, parm_variable, actionResult, additionalData) { 
    var additionalInputDataMap = additionalData.getAdditionalInputDataMap();
    var paramActions = additionalInputDataMap['input1'].getParameterActions(); // input1 stands for the input's name. Could be any input type
    for (i = 0; i < paramActions.length; i++) {
    var currentAction = paramActions[i];
    // Handle Add/Remove/Update Comment 
    if (currentAction.getType() === 'comment') {
    var hasDeleted = currentAction.hasDeleted(); // Checks if the user deleted the comment in the input form's UI
    if (hasDeleted && hasDeleted == true) {
    // Handle delete logic here, for example set the field where the comment is set to an empty string
    } 
    else 
    {
      var commentValue = currentAction.getCommentValue();
                  var commentLastUpdatedTimeStamp = currentAction.getLastUpdatedTimestamp();
    
    // handle here add/update comment to the result table for the specific record 
    }
    }
    }