---
sourceDocument: オーストラリア API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/api-reference

 Release :

    - australia

ft:locale :

    - ja-JP

ft:publication_title :

    - オーストラリア API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# TableUtils - グローバル

# TableUtils - グローバル {#ariaid-title1}

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

TableUtils スクリプトインクルードは、テーブル関連情報にアクセスするためのショートカットを提供します。

このクラスはサーバーサイドスクリプトで使用できます。

## TableUtils:TableUtils(文字列 tableName) {#ariaid-title2}

TableUtils クラスのインスタンスを作成します。
{#r_TU-TableUtils_S__table_jm5_34v_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| tableName | 文字列 | テーブル名 |
[表 : 1. パラメーター]

{#r_TU-TableUtils_S__table_jm5_34v_4t}  

    var tu = new TableUtils("incident");

## TableUtils:drop(文字列 tableName) {#ariaid-title3}

データベーステーブルを削除します。
注:  
細心の注意を払って使用してください。テーブルを削除すると、そのテーブルとそのすべてのデータが完全に削除されます。テーブルが拡張されている場合は、 dropTableAndExtensions を使用します。
{#r_TU-drop_S__table_ojq_gpv_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| tableName | 文字列 | ドロップするテーブルの名前 |
[表 : 2. パラメーター]

{#r_TU-drop_S__table_ojq_gpv_4t} {#r_TU-drop_S__table_pjq_gpv_4t__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 3. 返される内容]

{#r_TU-drop_S__table_pjq_gpv_4t}  

    var tu = new TableUtils();
    tu.drop("table_that_will_be_lost_forever");

出力:

    dropping table table_that_will_be_lost_forever
    Starting cache flush
    Cache flush complete
    TABLE DROP: admin dropped table table_that_will_be_lost_forever

## TableUtils - dropAndClean(文字列 tableName) {#ariaid-title4}

データベーステーブルを削除し、テーブルへの参照をクリーンアップします。
注:  
細心の注意を払って使用してください。データベーステーブルを削除すると、そのテーブルとそのすべてのデータが完全に削除されます。テーブルが拡張されている場合は、 dropTableAndExtensions を使用します。
{#r_TU-dropAndClean_S__table_mb5_15v_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| tableName | 文字列 | ドロップするテーブルの名前 |
[表 : 4. パラメーター]

{#r_TU-dropAndClean_S__table_mb5_15v_4t} {#r_TU-dropAndClean_S__table_nb5_15v_4t__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 5. 返される内容]

{#r_TU-dropAndClean_S__table_nb5_15v_4t}  

    var tu = new TableUtils();
    tu.dropAndClean("table_that_will_be_lost_forever");

出力:

    dropping table table_that_will_be_lost_forever
    Starting cache flush
    Cache flush complete
    TABLE DROP: admin dropped table table_that_will_be_lost_forever
    *** Script: removing gauges for table_that_will_be_lost_forever
    *** Script: removing forms for table_that_will_be_lost_forever
    *** Script: removing styles for table_that_will_be_lost_forever
    *** Script: removing forms sections for table_that_will_be_lost_forever
    *** Script: removing lists for table_that_will_be_lost_forever
    *** Script: removing related lists for table_that_will_be_lost_forever
    *** Script: removing references to table_that_will_be_lost_forever
    *** Script: removing dictionary entries for table_that_will_be_lost_forever
    Background message, type:info, message: Table deleted

## TableUtils:dropTableAndExtensions(文字列 tableName) {#ariaid-title5}

データベーステーブルとそのすべての拡張テーブルを削除し、テーブルへの参照をクリーンアップします。
注:  
細心の注意を払って使用してください。データベーステーブルを削除すると、そのテーブルとそのすべてのデータが完全に削除されます。
{#r_TU-dropTableAndExtensions_S__table_yhf_r5v_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| tableName | 文字列 | 削除するテーブル |
[表 : 6. パラメーター]

{#r_TU-dropTableAndExtensions_S__table_yhf_r5v_4t} {#r_TU-dropTableAndExtensions_S__table_zhf_r5v_4t__entry__2}

| タイプ | 説明 |
|-|-|
| なし |   |
[表 : 7. 返される内容]

{#r_TU-dropTableAndExtensions_S__table_zhf_r5v_4t}  

    var tu = new TableUtils();
    tu.dropTableAndExtensions("table_that_will_be_lost_forever");

出力:

    dropping table parent_table_that_will_be_lost_forever
    Starting cache flush
    Cache flush complete
    TABLE DROP: admin dropped table ext_table_that_will_be_lost_forever
    removing gauges for ext_table_that_will_be_lost_forever
    removing forms for ext_table_that_will_be_lost_forever
    removing styles for ext_table_that_will_be_lost_forever
    removing forms sections for ext_table_that_will_be_lost_forever
    removing lists for ext_table_that_will_be_lost_forever
    removing related lists for ext_table_that_will_be_lost_forever
    removing references to ext_table_that_will_be_lost_forever
    removing dictionary entries for ext_table_that_will_be_lost_forever
    Background message, type:info, message: Table deleted
    dropping table parent_table_that_will_be_lost_forever
    Starting cache flush
    Cache flush complete
    TABLE DROP: admin dropped table parent_table_that_will_be_lost_forever
    removing gauges for parent_table_that_will_be_lost_forever
    removing forms for parent_table_that_will_be_lost_forever
    removing styles for parent_table_that_will_be_lost_forever
    removing forms sections for parent_table_that_will_be_lost_forever
    removing lists for parent_table_that_will_be_lost_forever
    removing related lists for parent_table_that_will_be_lost_forever
    removing references to parent_table_that_will_be_lost_forever
    removing dictionary entries for parent_table_that_will_be_lost_forever
    Background message, type:info, message: Table deleted

## TableUtils:getAbsoluteBase() {#ariaid-title6}

テーブルの拡張元のベーステーブル名を返します。
注:  
cmdb_ci階層の下のテーブルでは、このメソッドは実際のベーステーブルである cmdb ではなく cmdb_ci を返します。
{#r_TU-getAbsoluteBase__table_c3f_gyv_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 8. パラメーター]

{#r_TU-getAbsoluteBase__table_c3f_gyv_4t} {#r_TU-getAbsoluteBase__table_d3f_gyv_4t__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | ベーステーブル名 |
[表 : 9. 返される内容]

{#r_TU-getAbsoluteBase__table_d3f_gyv_4t}  

    var table = new TableUtils("cmdb_ci_server");
    gs.print(table.getAbsoluteBase());

出力:cmdb_ci

## TableUtils:getAllExtensions() {#ariaid-title7}

テーブルを拡張するテーブルのリストを返します。ベーステーブルも含まれます。
{#r_TU-getAllExtensions__table_yq3_gxv_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 10. パラメーター]

{#r_TU-getAllExtensions__table_yq3_gxv_4t} {#r_TU-getAllExtensions__table_zq3_gxv_4t__entry__2}

| タイプ | 説明 |
|-|-|
| ArrayList | ベーステーブルを含む、テーブルを拡張するテーブルのリスト。 |
[表 : 11. 返される内容]

{#r_TU-getAllExtensions__table_zq3_gxv_4t}  

    var table = new TableUtils("task");
    gs.print(table.getAllExtensions());

出力：

    [task, incident, issue, kb_submission, sysapproval_group, change_request, change_request_imac, sc_task, 
    problem, sc_req_item, ticket, ast_transfer_order, planned_task, change_task, change_phase, sc_request]

## TableUtils:getHierarchy() {#ariaid-title8}

指定されたテーブルの階層に参加しているすべてのクラスのリストを返します。
{#r_TU-getHierarchy__table_lbl_ryv_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 12. パラメーター]

{#r_TU-getHierarchy__table_lbl_ryv_4t} {#r_TU-getHierarchy__table_mbl_ryv_4t__entry__2}

| タイプ | 説明 |
|-|-|
| ArrayList | 指定されたテーブルの階層内のすべてのクラスのリスト。 |
[表 : 13. 返される内容]

{#r_TU-getHierarchy__table_mbl_ryv_4t}  

    var table = new TableUtils("cmdb_ci_server");
    gs.print(table.getHierarchy());

出力:\[cmdb_ci_server、cmdb_ci_computer、cmdb_ci_hardware、cmdb_ci、cmdb_ci_mainframe、cmdb_ci_linux_server、cmdb_ci_mainframe_lpar、cmdb_ci_esx_server、cmdb_ci_unix_server、cmdb_ci_solaris_server、cmdb_ci_hpux_server、cmdb_ci_aix_server、cmdb_ci_osx_server、cmdb_ci_netware_server、cmdb_ci_win_server\]

## TableUtils:getTables() {#ariaid-title9}

テーブル階層を返します。
{#r_TU-getTables__table_z1t_3wv_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 14. パラメーター]

{#r_TU-getTables__table_z1t_3wv_4t} {#r_TU-getTables__table_abt_3wv_4t__entry__2}

| タイプ | 説明 |
|-|-|
| ArrayList | 親階層内のテーブル名のリスト。 |
[表 : 15. 返される内容]

{#r_TU-getTables__table_abt_3wv_4t}  

    // Get the hierarchy of tables
    var table = new TableUtils("cmdb_ci_computer");
    var tableArrayList = table.getTables();

    // Use the j2js method to convert the Java ArrayList to JavaScript
    gs.include("j2js");
    var tableArray = j2js(tableArrayList);

    // Write the value of each element in the JavaScript array
    var i = 0;
    while ( i < tableArray.length ) {
    gs.print("Table with index " + i + ": " + tableArray[i]);
    i++;
    }

出力：

    Table with index 0: cmdb_ci_computer
    Table with index 1: cmdb_ci_hardware
    Table with index 2: cmdb_ci
    Table with index 3: cmdb

## TableUtils:getTableExtensions() {#ariaid-title10}

テーブルを拡張するテーブルのリストを返します。
{#r_TU-getTableExtensions__table_sfl_twv_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 16. パラメーター]

{#r_TU-getTableExtensions__table_sfl_twv_4t} {#r_TU-getTableExtensions__table_tfl_twv_4t__entry__2}

| タイプ | 説明 |
|-|-|
| ArrayList | テーブルを拡張するテーブル名のリスト。 |
[表 : 17. 返される内容]

{#r_TU-getTableExtensions__table_tfl_twv_4t}  
この例では、このインスタンスの 58 個のテーブルがコンピューター \[cmdb_ci_computer\] テーブルを拡張していることを示しています。(出力は以下に要約されています。

    // Get the tables that extend the table
    var table = new TableUtils("cmdb_ci_computer");
    var tableArrayList = table.getTableExtensions();
     
    // Use the j2js method to convert the Java ArrayList to JavaScript
    gs.include("j2js");
    var tableArray = j2js(tableArrayList);
     
    // Write the value of each element in the JavaScript array
    var i = 0;
    while ( i < tableArray.length ) {
      gs.print("Table with index " + i + ": " + tableArray[i]);
      i++;
    }

出力：

    Table with index 0: cmdb_ci_mainframe_hardware
    Table with index 1: cmdb_ci_handheld_computing
    Table with index 2: cmdb_ci_ucs_blade
    Table with index 3: cmdb_ci_storage_switch
    Table with index 4: cmdb_ci_server
    Table with index 5: cmdb_ci_hmc_server
    ...
    Table with index 56: cmdb_ci_pc_hardware
    Table with index 57: cmdb_ci_ucs_rack_unit

## TableUtils:hasExtensions() {#ariaid-title11}

テーブルが拡張されたかどうかを判断します。
{#r_TU-hasExtensions__table_lby_m1w_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 18. パラメーター]

{#r_TU-hasExtensions__table_lby_m1w_4t} {#r_TU-hasExtensions__table_mby_m1w_4t__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | テーブルに拡張子がある場合は True。 |
[表 : 19. 返される内容]

{#r_TU-hasExtensions__table_mby_m1w_4t}  

    var table = new TableUtils("cmdb_ci_server");
    gs.print(table.hasExtensions());

出力：

    true

## TableUtils:isBaseClass() {#ariaid-title12}

テーブルが基底クラスであるかどうか、つまり親がなく、拡張があるかどうかを判断します。
たとえば、タスクは別のテーブルから拡張されたのではなく、そこから拡張されたテーブルがあるため、基底クラスです。Sys_user は親を持たず、拡張子も持たないため、基底クラスではありません。
{#r_TU-isBaseClass__table_k5p_w1w_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 20. パラメーター]

{#r_TU-isBaseClass__table_k5p_w1w_4t} {#r_TU-isBaseClass__table_l5p_w1w_4t__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | テーブルが基底クラステーブルであるかどうか (親はないが拡張はある) かどうかを示すフラグ。 有効な値： * true:テーブルは基底クラスです。 * false:テーブルは基底クラスではありません。 {#r_TU-isBaseClass__ul_wp1_hjt_43b} |
[表 : 21. 返される内容]

{#r_TU-isBaseClass__table_l5p_w1w_4t}  

    var table = new TableUtils("task");
    gs.print("Task is base class: " + table.isBaseClass());
     
    var table = new TableUtils("sys_user");
    gs.print("User is base class: " + table.isBaseClass());

出力：

     Task is base class: true
    User is base class: false

## TableUtils:isSoloClass() {#ariaid-title13}

テーブルに親がなく、拡張がないかどうかを判別します。
{#r_TU-isSoloClass__table_lv2_nbw_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 22. パラメーター]

{#r_TU-isSoloClass__table_lv2_nbw_4t} {#r_TU-isSoloClass__table_mv2_nbw_4t__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | テーブルに親がなく、そこから拡張されるテーブルがない場合は True。 |
[表 : 23. 返される内容]

{#r_TU-isSoloClass__table_mv2_nbw_4t}  

    var table = new TableUtils("task");
    gs.print("task is solo class: " + table.isSoloClass());
     
    var table = new TableUtils("cmdb_ci_win_server");
    gs.print("cmdb_ci_win_server is solo class: " + table.isSoloClass());
     
    var table = new TableUtils("sys_user");
    gs.print("sys_user is solo class: " + table.isSoloClass());

出力：

    task is solo class: false
    cmdb_ci_win_server is solo class: false
    sys_user is solo class: true

## TableUtils:tableExists() {#ariaid-title14}

テーブルが存在するかどうかを確認します。
{#r_TU-tableExists__table_txx_x4v_4t__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 24. パラメーター]

{#r_TU-tableExists__table_txx_x4v_4t} {#r_TU-tableExists__table_uxx_x4v_4t__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | テーブルが存在する場合は True。 |
[表 : 25. 返される内容]

{#r_TU-tableExists__table_uxx_x4v_4t}  

    var table = new TableUtils("my_table");
    gs.print("Does 'my_table' exist? " + table.tableExists());

出力:「my_table」は存在しますか?false

