v_table – スコープ、グローバル

  • リリースバージョン: Yokohama
  • 更新日 2025年01月30日
  • 所要時間:3分
  • v_table API は、スクリプト可能オブジェクトを使用してリモートテーブルに行を追加するメソッドを提供します。

    この API では、リモートテーブルプラグイン (com.glide.script.vtable) を有効にする必要があります。 詳細については、「 リモートテーブルとスクリプトを使用した外部データの取得」を参照してください。

    v_queryスクリプト可能オブジェクトを使用して、リモートテーブルをクエリします。

    v_table:addRow(オブジェクト行)

    リモートテーブルに行を追加します。

    表 : 1. パラメーター
    名前 タイプ 説明
    オブジェクト キーがフィールド名であるフィールド名と値マップを含む JavaScript オブジェクト ( 例:{number: "INC0001", sys_id: "a34"})。
    { "<field name>": "value" }
    
    row.<field 値> 文字列 選択したフィールドの値を表します。必須フィールドはありませんが、少なくともsys_idを入力してください。

    sys_idフィールドと値のみをリストする例:

    { "sys_id": "<uniqueID>" }
    
    表 : 2. 戻り値
    タイプ 説明
    ブール 行がリモートテーブルに追加されたかどうかを示すフラグ。
    有効な値:
    • true:成功。
    • false:行が追加されませんでした。

    次の例は、 RESTMessageV2 API を使用して、外部バンクアプリケーションに対する REST 呼び出しを作成して実行する方法を示しています。このスクリプトは、 addRow() メソッドを使用して、戻り結果をリモートテーブルに格納する方法を示しています。

    (function executeQuery (v_table, v_query) {
      // Parameters needed in the request body of the REST endpoint
      var requestBody = {
        'financial_account':v_query.getParameter('financial_account')
      };
    
      // Instantiate the RESTMessageV2 object
      var request = new sn_ws.RESTMessageV2();
      // Set the HTTP method as "GET"
      request.setHttpMethod('get');
      // URL of the endpoint on the bank application
      request.setEndpoint('https://<yourbankapphost>/api/getTransactionDetails');
      // Request body as a string
      request.setRequestBody(JSON.stringify(requestBody));
      // Call the REST endpoint
      var response = request.execute();
      // Get the response body
      var responseBody = response.getBody();
      // Parse the response body into an object
      var responseObj = JSON.parse(responseBody);
    
      // Store the response body into a virtual table
      v_table.addRow({
        sys_id: gs.generateGUID(),
        amount: responseObj.amount,
        description: responseObj.description,
        posting_date: responseObj.posting_date,
        transaction_date: responseObj.transaction_date
      });
    
    }) (v_table, v_query);