---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# action - Scoped, Global

# action - Scoped, Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 4 minutes to read

The action API provides methods to handle data for URLs in a UI action script.
Use this API to configure UI actions with which users can interact. Use these scripts in the UI Action \[sys_ui_action\] table. For information, see [UI actions](https://www.servicenow.com/docs/access?context=t_EditingAUIAction&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).

Methods for this API are referred to by the variable name 'action' in any server-side
JavaScript. To learn more, see [Creating interactions with UI actions](https://developer.servicenow.com/blog.do?p=/post/training-ui-action-101/).

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

Gets a GlideURI object to determine the user view.
{#Action_getGlideURI__table_dxr_lfj_nkb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#Action_getGlideURI__table_dxr_lfj_nkb} {#Action_getGlideURI__table_exr_lfj_nkb__entry__2}

| Type | Description |
|-|-|
| Object | GlideURI object representing the URI parameter of the user view. * [GlideURI - Scoped](https://www.servicenow.com/docs/7WZ8W4hOiMVJV1Lgu_Q6Kg#c_GlideURIScopedAPI "The GlideURI API provides methods to handle URI parameters in a scoped application.") * [GlideURI - Global](https://www.servicenow.com/docs/F44W4HfW0NXWigj_wrJrmA#GlideURIGlobalAPI "The GlideURI API provides methods to handle URI parameters in a global application.") {#Action_getGlideURI__ul_f4h_5lj_5mb} Note: Any other returned value is considered an error, including null. |
[Table 2. Returns]

{#Action_getGlideURI__table_exr_lfj_nkb}  
The following example shows how to get the user view and set the redirect URL to the
service catalog home page.

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

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

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

Gets the URL of the return page in view after a UI action is complete.
{#Action_getReturnURL__table_db4_ffj_nkb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 3. Parameters]

{#Action_getReturnURL__table_db4_ffj_nkb} {#Action_getReturnURL__table_eb4_ffj_nkb__entry__2}

| Type | Description |
|-|-|
| String | URL of the return page in view after a UI action is complete. |
[Table 4. Returns]

{#Action_getReturnURL__table_eb4_ffj_nkb}  

    action.getReturnURL();

## action - getURLParameter(String parameterName) {#ariaid-title4}

Gets the value of a URL parameter.
{#Action_getURLParameter_S__table_alv_y2j_nkb__entry__3}

| Name | Type | Description |
|-|-|-|
| parameterName | String | Name of the URL parameter name to be queried for the URL parameter value. |
[Table 5. Parameters]

{#Action_getURLParameter_S__table_alv_y2j_nkb} {#Action_getURLParameter_S__table_blv_y2j_nkb__entry__2}

| Type | Description |
|-|-|
| String | URL parameter value. |
[Table 6. Returns]

{#Action_getURLParameter_S__table_blv_y2j_nkb}  

    action.getURLParameter('sysparm_query');

## action - openGlideRecord(Object gr) {#ariaid-title5}

Opens a page with a GlideRecord in the user view.
{#Action_openGlideRecord_O__table_sy5_bfj_nkb__entry__3}

| Name | Type | Description |
|-|-|-|
| gr | [GlideRecord](https://www.servicenow.com/docs/Z64TK~kWnpWTEG5bCPvZuQ#c_GlideRecordScopedAPI "The scoped GlideRecord API is used for database operations.") | GlideRecord of the page to be opened in the user view. |
[Table 7. Parameters]

{#Action_openGlideRecord_O__table_sy5_bfj_nkb} {#Action_openGlideRecord_O__table_ty5_bfj_nkb__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 8. Returns]

{#Action_openGlideRecord_O__table_ty5_bfj_nkb}  
The following example shows how to include the caller name and incident description created from an interaction record. For more details, see [Customizing Configurable Workspace with declarative actions](https://www.servicenow.com/docs/access?context=declarative-actions-landing&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US).

    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(Boolean noPop) {#ariaid-title6}

Indicates whether to enable or disable pop-up windows on the page in the current
view.
{#Action_setNoPop_B__table_mms_gfj_nkb__entry__3}

| Name | Type | Description |
|-|-|-|
| noPop | Boolean | Flag indicating whether to enable or disable pop-up windows on the page: * true: Disables pop-up windows. * false: Default. Enables pop-up windows. {#Action_setNoPop_B__ul_qmz_fwj_nkb} |
[Table 9. Parameters]

{#Action_setNoPop_B__table_mms_gfj_nkb} {#Action_setNoPop_B__table_nms_gfj_nkb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 10. Returns]

{#Action_setNoPop_B__table_nms_gfj_nkb}  
The following example shows how to disable pop-up windows for a UI action.


    action.setNoPop(true);

## action - setRedirectURL(Object URL) {#ariaid-title7}

Sets the redirect URI for this transaction, which determines the next page the user
sees.
For use cases:

* [Create a UI routing
  action](https://www.servicenow.com/docs/access?context=useful-client-side-scripts&version=xanadu&pubname=xanadu-application-development&section=t_CreateAUIRoutingAction&ft:locale=en-US)
* [Create knowledge articles from HR
  cases](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}

| Name | Type | Description |
|-|-|-|
| URL | Object | URL to set as the redirect. You can provide the URL as a string or a [GlideRecord](https://www.servicenow.com/docs/Z64TK~kWnpWTEG5bCPvZuQ#c_GlideRecordScopedAPI "The scoped GlideRecord API is used for database operations."). If you pass the URL as a GlideRecord, this value takes the focus to that record's form. |
[Table 11. Parameters]

{#Action_setRedirectURL_O__table_bdm_2fj_nkb} {#Action_setRedirectURL_O__table_cdm_2fj_nkb__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 12. Returns]

{#Action_setRedirectURL_O__table_cdm_2fj_nkb}  
The following example shows how to redirect a user to a URL from a UI action using the
[current](https://www.servicenow.com/docs/access?context=c_ScriptableServiceCatalogVariables&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US) variable.

    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();}

The following example shows how to create a new incident record and redirect to the new incident after a UI action completes.

    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(Object URL) {#ariaid-title8}

Sets the return URI for this transaction after a UI action is complete. You can use
this method to determine what page the user has in view when they return from
submit.
{#Action_setReturnURL_O__table_bdm_2fj_nkb__entry__3}

| Name | Type | Description |
|-|-|-|
| URL | Object | URI to set as the return location after a UI action is complete. You can provide the URL as a string or a [GlideRecord](https://www.servicenow.com/docs/Z64TK~kWnpWTEG5bCPvZuQ#c_GlideRecordScopedAPI "The scoped GlideRecord API is used for database operations."). |
[Table 13. Parameters]

{#Action_setReturnURL_O__table_bdm_2fj_nkb} {#Action_setReturnURL_O__table_cdm_2fj_nkb__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 14. Returns]

{#Action_setReturnURL_O__table_cdm_2fj_nkb}  
The following example enables the user to select the UI action to create a change record using information from the problem record and the change template. After the change, the user returns to [current](https://www.servicenow.com/docs/access?context=c_ScriptableServiceCatalogVariables&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US) view. For more information, see [Scripted templates](https://www.servicenow.com/docs/access?context=r_ScriptedTemplates&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US). For more use cases, see [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(String parameterName, String parameterValue) {#ariaid-title9}

Sets a URL parameter name and value.
{#Action_setURLParameter_S_S__table_elv_z2j_nkb__entry__3}

| Name | Type | Description |
|-|-|-|
| parameterName | String | Name of the URL parameter. |
| parameterValue | String | Value of the parameter. |
[Table 15. Parameters]

{#Action_setURLParameter_S_S__table_elv_z2j_nkb} {#Action_setURLParameter_S_S__table_flv_z2j_nkb__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 16. Returns]

{#Action_setURLParameter_S_S__table_flv_z2j_nkb}  

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


