---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# action - スコープ対象、グローバル

# action - スコープ対象、グローバル {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：9分

アクション API は、UI アクションスクリプト内の URL のデータを処理するメソッドを提供します。
この API を使用して、ユーザーが操作できる UI アクションを構成します。UI アクション \[sys_ ui_action\] テーブル内のこれらのスクリプトを使用します。詳細については、「 [UI アクション](https://www.servicenow.com/docs/access?context=t_EditingAUIAction&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)」を参照してください。

この API のメソッドは、サーバー側の JavaScript で「action」という変数名で参照されます。詳細については、「[UI アクションによるインタラクションの作成](https://developer.servicenow.com/blog.do?p=/post/training-ui-action-101/)」を参照してください。

## action - getGlideURI() {#ariaid-title2}

ユーザービューを決定する GlideURI オブジェクトを取得します。
{#Action_getGlideURI__table_dxr_lfj_nkb__entry__3}

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

{#Action_getGlideURI__table_dxr_lfj_nkb} {#Action_getGlideURI__table_exr_lfj_nkb__entry__2}

| タイプ | 説明 |
|-|-|
| オブジェクト | ユーザービューの URI パラメーターを表す GlideURI オブジェクト。 * [GlideURI - スコープ指定](https://servicenow-prod.fluidtopics.net/by_ZGwM32B88rDlUelfMcg#c_GlideURIScopedAPI "GlideURI API は、スコープ対象のアプリケーションで URI パラメーターを処理するメソッドを提供します。") * [GlideURI - グローバル](https://servicenow-prod.fluidtopics.net/ztmrdcwmFp1Dg4W5cRFVog#GlideURIGlobalAPI "GlideURI API は、グローバルアプリケーションで URI パラメーターを処理するためのメソッドを提供します。") {#Action_getGlideURI__ul_f4h_5lj_5mb} 注: null を含むその他の戻り値はエラーと見なされます。 |
[表 : 2. 返される内容]

{#Action_getGlideURI__table_exr_lfj_nkb}  
次の例は、ユーザービューを取得し、サービスカタログのホームページへのリダイレクト URL を設定する方法を示しています。

    var uri = action.getGlideURI();
    var path = 'catalog_home.do';

    uri.set('sysparm_view', 'catalog_default');
    action.setRedirectURL(uri.toString(path));

## action - getReturnURL() {#ariaid-title3}

UI アクションが完了した後に表示されるページの URL を取得します。
{#Action_getReturnURL__table_db4_ffj_nkb__entry__3}

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

{#Action_getReturnURL__table_db4_ffj_nkb} {#Action_getReturnURL__table_eb4_ffj_nkb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | UI アクションが完了した後に表示されるページの URL。 |
[表 : 4. 返される内容]

{#Action_getReturnURL__table_eb4_ffj_nkb}  

    action.getReturnURL();

## action - getURLParameter(文字列 parameterName) {#ariaid-title4}

URL パラメーターの値を取得します。
{#Action_getURLParameter_S__table_alv_y2j_nkb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| parameterName | 文字列 | URL パラメーター値を照会する URL パラメーターの名前。 |
[表 : 5. パラメーター]

{#Action_getURLParameter_S__table_alv_y2j_nkb} {#Action_getURLParameter_S__table_blv_y2j_nkb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | URL パラメーター値。 |
[表 : 6. 返される内容]

{#Action_getURLParameter_S__table_blv_y2j_nkb}  

    action.getURLParameter('sysparm_query');

## action - openGlideRecord(オブジェクト gr) {#ariaid-title5}

ユーザービューで GlideRecord を含むページを開きます。
{#Action_openGlideRecord_O__table_sy5_bfj_nkb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| gr | [GlideRecord](https://servicenow-prod.fluidtopics.net/DKnkjnu3r0c8j~e5s2NNhg#c_GlideRecordScopedAPI "スコープ付き GlideRecord API はデータベース操作に使用されます。") | ユーザービューで開くページの GlideRecord。 |
[表 : 7. パラメーター]

{#Action_openGlideRecord_O__table_sy5_bfj_nkb} {#Action_openGlideRecord_O__table_ty5_bfj_nkb__entry__2}

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

{#Action_openGlideRecord_O__table_ty5_bfj_nkb}  
次の例は、インタラクションレコードから作成された発信者名とインシデントの説明を含める方法を示しています。詳細については、「 ワークスペースでのカスタム UI アクションの設定」を参照してください。

    if(current.update()){
      var inc = new GlideRecord("incident");
      inc.newRecord();
      inc.caller_id = current.opened_for;
      inc.short_description = current.short_description;
      action.openGlideRecord(inc);
    }

## action - setNoPop(ブール noPop) {#ariaid-title6}

現在のビューのページでポップアップウィンドウを有効にするか無効にするかを示します。
{#Action_setNoPop_B__table_mms_gfj_nkb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| noPop | ブーリアン | ページでポップアップウィンドウを有効にするか無効にするかを示すフラグ。 * true：ポップアップウィンドウを無効にします。 * false：デフォルトです。ポップアップウィンドウを有効にします。 {#Action_setNoPop_B__ul_qmz_fwj_nkb} |
[表 : 9. パラメーター]

{#Action_setNoPop_B__table_mms_gfj_nkb} {#Action_setNoPop_B__table_nms_gfj_nkb__entry__2}

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

{#Action_setNoPop_B__table_nms_gfj_nkb}  
次の例は、UI アクションのポップアップウィンドウを無効にする方法を示しています。


    action.setNoPop(true);

## action - setRedirectURL(オブジェクト URL) {#ariaid-title7}

このトランザクションのリダイレクト URI を設定します。リダイレクト URI は、ユーザーに表示される次のページを決定します。
ユースケース：

* [UI ルーティングアクションの作成](https://www.servicenow.com/docs/access?context=useful-client-side-scripts&version=xanadu&pubname=xanadu-application-development&section=t_CreateAUIRoutingAction&ft:locale=en-US)
* [HR ケースからのナレッジ記事の作成](https://www.servicenow.com/docs/access?context=ui-action-hrcase-article&version=xanadu&pubname=xanadu-servicenow-platform&ft:locale=en-US)
* [Task relationships with UI actions](https://www.servicenow.com/docs/access?context=r_UIActions&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)
{#Action_setRedirectURL_O__ul_i1s_2qk_lmb}
{#Action_setRedirectURL_O__table_bdm_2fj_nkb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| URL | オブジェクト | リダイレクトとして設定する URL。URL は文字列または [GlideRecord](https://servicenow-prod.fluidtopics.net/DKnkjnu3r0c8j~e5s2NNhg#c_GlideRecordScopedAPI "スコープ付き GlideRecord API はデータベース操作に使用されます。")として指定できます。URL を GlideRecord として渡すと、この値によってそのレコードのフォームにフォーカスが移動します。 |
[表 : 11. パラメーター]

{#Action_setRedirectURL_O__table_bdm_2fj_nkb} {#Action_setRedirectURL_O__table_cdm_2fj_nkb__entry__2}

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

{#Action_setRedirectURL_O__table_cdm_2fj_nkb}  
次の例は、 [current](https://www.servicenow.com/docs/access?context=c_ScriptableServiceCatalogVariables&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US) 変数を使用して UI アクションから URL にユーザーをリダイレクトする方法を示しています。

    var fixchg = new GlideRecord("change_request");
    fixchg.short_description= current.short_description;
    fixchg.comments= current.comments.getHTMLValue();
    // fixchg.parent = current.sys_id;
    fixchg.insert();
    FixChange();
     
    gs.addInfoMessage("Change "+ fixchg.number+" created");
    action.setRedirectURL(current);
    action.setReturnURL(fixchg);
     
    function FixChange(){
    var m2m = new GlideRecord('task_rel_task');
    m2m.initialize();
    m2m.child= current.sys_id;
    m2m.parent= fixchg.sys_id;
    m2m.type.setDisplayValue("Fixes::Fixed by");
    m2m.insert();}

次の例は、新しいインシデントレコードを作成し、UI アクションの完了後に新しいインシデントにリダイレクトする方法を示しています。

    var reqItem = current.u_item;
    var requestedFor = current.u_requested_for;
    var location = current.location;

    if(current.u_incident_request == 'Incident'){
      //Create a new incident record and redirect to the new incident
      var rec = new GlideRecord('incident');
      rec.initialize();
      rec.caller_id = requestedFor;
      rec.location = location;
      rec.insert();
      action.setRedirectURL(rec);
    }

    if(current.u_incident_request == 'Request'){
      //Build the url and route the user to the request item
      var url = '';
      if(current.u_item.sys_class_name == 'sc_cat_item_guide'){
        url = 'com.glideapp.servicecatalog_cat_item_guide_view.do?sysparm_initial=true&sysparm_guide=' + 
          reqItem + '&sysparm_user=' + requestedFor + '&sysparm_location=' + location;
      }
      else{
        url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem + '&sysparm_user=' +  
          requestedFor + '&sysparm_location=' + location;
      }
      action.setRedirectURL(url);
    }

## action - setReturnURL(オブジェクト URL) {#ariaid-title8}

UI アクションが完了した後に、このトランザクションのリターン URI を設定します。このメソッドを使用して、ユーザーが送信から戻ったときに表示されるページを決定できます。
{#Action_setReturnURL_O__table_bdm_2fj_nkb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| URL | オブジェクト | UI アクションが完了した後に戻る場所として設定する URI。URL は文字列または [GlideRecord](https://servicenow-prod.fluidtopics.net/DKnkjnu3r0c8j~e5s2NNhg#c_GlideRecordScopedAPI "スコープ付き GlideRecord API はデータベース操作に使用されます。")として指定できます。 |
[表 : 13. パラメーター]

{#Action_setReturnURL_O__table_bdm_2fj_nkb} {#Action_setReturnURL_O__table_cdm_2fj_nkb__entry__2}

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

{#Action_setReturnURL_O__table_cdm_2fj_nkb}  
次の例では、ユーザーが UI アクションを選択し、問題レコードと変更テンプレートの情報を使用して変更レコードを作成できるようにしています。変更後、ユーザーは [現在の](https://www.servicenow.com/docs/access?context=c_ScriptableServiceCatalogVariables&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US) ビューに戻ります。詳細については、「 [スクリプト化されたテンプレート](https://www.servicenow.com/docs/access?context=r_ScriptedTemplates&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)」を参照してください。その他のユースケースについては、「 [Task relationships with UI actions](https://www.servicenow.com/docs/access?context=r_UIActions&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US)」を参照してください。

    var change = new GlideRecord("change_request");
    change.initialize();
    change.short_description = current.short_description;
    change.description = current.u_details;
    change.cmdb_ci = current.u_service;
    change.priority = current.priority;
    change.requested_by = current.caller_id;
    change.assignment_group.setDisplayValue('Change & Release');
    change.u_status = 'New';
    change.parent = current.number;
    change.applyTemplate("standard_rfc");
    current.rfc = change.insert();
    current.comments = 'Change ' + change.number + ' created.';

    var mySysID = current.update();

    gs.addInfoMessage("Change " + change.number + " created");
    action.setRedirectURL(change);
    action.setReturnURL(current);

## action - setURLParameter(文字列 parameterName, 文字列 parameterValue) {#ariaid-title9}

URL パラメーターの名前と値を設定します。
{#Action_setURLParameter_S_S__table_elv_z2j_nkb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| parameterName | 文字列 | URL パラメーターの名前。 |
| parameterValue | 文字列 | パラメーターの値。 |
[表 : 15. パラメーター]

{#Action_setURLParameter_S_S__table_elv_z2j_nkb} {#Action_setURLParameter_S_S__table_flv_z2j_nkb__entry__2}

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

{#Action_setURLParameter_S_S__table_flv_z2j_nkb}  

    action.setURLParameter('sysparm_query', 'priority=2^active=true');


