---
sourceDocument: オーストラリアのカスタマーサービス管理 (CSM)
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/customer-service-management

 Release :

    - australia

ft:locale :

    - ja-JP

ft:publication_title :

    - オーストラリアのカスタマーサービス管理 (CSM)

ft:clusterId :

    - csm

bundleId :

    - csm

workflow :

    - Customer and Industry


---

# リモートテーブルスクリプトのサンプル

# サードパーティデータ統合のサンプルリモートテーブルスクリプト {#ariaid-title1}

* リリースバージョン: Australia
* 
* 更新日 2026年03月12日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：3分

リモートテーブルスクリプトは、サードパーティアプリケーションからレコードをプルするように設計することができます。このスクリプトは、リモートテーブル内のデータにアクセスするクエリが作成されたときに呼び出されます。
統合ハブでリモートテーブルを使用するには、サードパーティアプリケーションと連携する統合ハブスポークを特定する必要があります。スポークは、アプリケーションからさまざまなデータのサブセットを取得するために作成されたフローデザイナーアクションで構成されます。

たとえば、Salesforce アプリケーションからアカウント情報を取得する必要がある場合は、Salesforce スポークとすべてのアカウントを取得アクションを使用します。このアクションにアクセスするリモートテーブルスクリプトの例については、以下を参照してください。  

    (function executeQuery(v_table, v_query) {
      try {
        // prepare inputs for the spoke actions 
        // Get All Accounts action does not have any inputs).
        var inputs = {};

        // call spoke action
        var outputs = sn_fd.FlowAPI.executeAction(
                                    "sn_salesforce_spok.get_all_accounts", inputs);

        // check if Action was completed successfully
        if (outputs.status != "Success") {
          throw new Error(outputs.errorMessage);
        }

        // extract payload from the action outputs
        var accounts = outputs.accounts.data;

        // map action output data to the remote table columns and Sys Id
        for (var i = 0; i < accounts.length; i++) {
          v_table.addRow({
            "u_sf_account_id": accounts[i].name,
            "u_sf_account_name": accounts[i].label,
            // assign remote table Sys Id to the primary key of the third-party
            // record
            "sys_id": accounts[i].name,
          });
        }

      // process errors 
      } catch (error) {
         gs.addErrorMessage("Error trying to retrieve  Salesforce Accounts." +
                            "Please contact System Administrator.");
         gs.addErrorMessage("System Error: " + error.message);
      }

    })(v_table, v_query);

注:  
リモートテーブルスクリプトから呼び出せない統合ハブアクションもあります。具体的には、スクリプトからデータストリームアクションを呼び出すことはできません。使用するアクションがデータストリームアクションである場合は、REST ステップに基づいて独自のアクションを作成する必要があります。アクションを簡単に作成するには、既存のアクションをコピーしてから、目標を達成するために変更することが必要です。カスタムスポークアクションの例については、「[リモートテーブル定義で使用する機会を取得するための Salesforce スポークアクションの作成](https://servicenow-prod.fluidtopics.net/vt30Oqp9VEg7m058juO0bg "Salesforce スポークは、機会レコードのメタデータを取得して新しい機会を作成するアクションを提供します。")」のトピックを参照してください。

