---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideSPUtil - Global

# GlideSPUtil - Global {#ariaid-title1}

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

The GlideSPUtil API provides utility methods to perform common backend functions that support a Service Portal.  
Available utility methods:

* Resolve variables specified in the Dynamic page variables \[sp_page_title_variable\] table associated with a specified Service Portal page located in the Page \[sp_page\] table.
* Other methods

For additional information, see Service Portal pages.

## GlideSPUtil - GlideSPUtil() {#ariaid-title2}

Instantiates a GlideSPUtil object.
{#GSPUtil-GlideSPUtil__table_n14_4gg_hvb__entry__3}

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

{#GSPUtil-GlideSPUtil__table_n14_4gg_hvb}  
The following code example shows how to instantiate a GlideSPUtil object before calling any
of its associated methods.

    function() {
      var spUtil = new GlideSPUtil();
      var pageGR = spUtil.getPageRecordWithPageRoute('kb_article', '81b75d3147032100ba13a5554ee4902b', false);
      var queryParams = RP.getParameters();
      var hrUrl = spUtil.getHumanReadableUrl(pageGR, queryParams);
    }

## GlideSPUtil - getHumanReadableUrl() {#ariaid-title3}

Considers
'id'
query parameter to identify the portal page (pageGR) and
uses
query string of the current transaction to call getHumanReadableUrl(GlideRecord pageGR, String
queryString) and returns the final human readable.
{#GSPUtil-getHumReadUrl__table_rr4_wyg_hvb__entry__3}

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

{#GSPUtil-getHumReadUrl__table_rr4_wyg_hvb} {#GSPUtil-getHumReadUrl__table_sr4_wyg_hvb__entry__2}

| Type | Description |
|-|-|
| String | Human readable URL for the specified Service Portal record with the variables replaced with the contents of the queryParams string map. |
[Table 3. Returns]

{#GSPUtil-getHumReadUrl__table_sr4_wyg_hvb}  
The following code example
shows
how to.

    function() {
      var spUtil = new GlideSPUtil();
      var hrUrl = spUtil.getHumanReadableUrl();
    }

Output:

```

```

## GlideSPUtil - getHumanReadableUrl(GlideRecord pageGR, String queryParams) {#ariaid-title4}

Converts the passed queryParms string parameter into a string map
and then resolves the variables in the
"Human
readable url structure" string provided in the sp_page record and returns the
final
human readable part of the URL.
{#GSPUtil-getHumReadUrl_GR_S__table_vjm_wwg_hvb__entry__3}

| Name | Type | Description |
|-|-|-|
| pageGR | GlideRecord | GlideRecord object of the record in the Page \[sp_page\] table on which to resolve the URL variables. |
| queryString | String | Query string. |
[Table 4. Parameters]

{#GSPUtil-getHumReadUrl_GR_S__table_vjm_wwg_hvb} {#GSPUtil-getHumReadUrl_GR_S__table_wjm_wwg_hvb__entry__2}

| Type | Description |
|-|-|
| String | Human readable URL for the specified Service Portal record with the variables replaced with the contents of the queryParams string map. |
[Table 5. Returns]

{#GSPUtil-getHumReadUrl_GR_S__table_wjm_wwg_hvb}  
The following code example
shows
how to.

    function() {
      var spUtil = new GlideSPUtil();
      var pageGR = spUtil.getPageRecordWithPageRoute('kb_article', '81b75d3147032100ba13a5554ee4902b', false);
      var queryString = GlideTransaction.get().getRequest().getQueryString();
      var hrUrl = spUtil.getHumanReadableUrl(pageGR, queryParams);
    }

Output:

```

```

## GlideSPUtil - getHumanReadableUrl(GlideRecord pageGR, StringMap queryParams) {#ariaid-title5}

Resolves the variables in the Human readable url structure field of the passed-in Service Portal template page object and returns a URL containing the specified query parameters and the resolved human readable parameters.
Use human readable keywords in a URL to:

* Enable your customers to better understand the purpose of the URL when it is not in the context of the associated page.
* Provide search engines with keywords to better locate the page.

For example, instead of just having a URL that contains unrecognisable key-value pairs such
as this:

`https://instance_name.servicenow.com/sp/en?id=sc_cat_item&sys_id=ec80c13297968d1021983d1e6253af32&sysparm_catgory=1e80c15697969f1032083d1e6253be15`

You can add the item name to the URL so it is easier to understand the purpose of the
URL:

`https://instance_name.servicenow.com/sp/en/apple-iphone-13?id=sc_cat_item&sys_id=ec80c13297968d1021983d1e6253af32&sysparm_catgory=1e80c15697969f1032083d1e6253be15`

Before you can use this method, you must define the dynamic page variables that are available for each of the Service Portal templates for which you want to include dynamic content in the URL. For details on adding these variables, see [Add human readable keywords to page URLs](https://www.servicenow.com/docs/access?context=add-human-readable-keywords-page-urls&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US).
{#GSPUtil-getHumReadUrl_GR_SM__table_dht_dpg_hvb__entry__3}

| Name | Type | Description |
|-|-|-|
| pageGR | GlideRecord | GlideRecord object of theService Portal template page for which to resolve the dynamic URL variables. Located in the Page \[sp_page\] table. |
| queryParams | StingMap | URL query parameters to use to obtain the desired Service Portal page. For example: { "id": "sc_cat_item", "sys_id": "ec80c13297968d1021983d1e6253af32", "sysparm_catgory": "1e80c15697969f1032083d1e6253be15" } |
[Table 6. Parameters]

{#GSPUtil-getHumReadUrl_GR_SM__table_dht_dpg_hvb} {#GSPUtil-getHumReadUrl_GR_SM__table_eht_dpg_hvb__entry__2}

| Type | Description |
|-|-|
| String | URL containing the resolved human readable elements for the dynamic variables specified in the Service Portal template page. For example, if the defined dynamic variable is %item_name, the URL contains the name of the item that the user selected, such as "apple-iphone-13, and all of the specified query parameters: `https://instance_name.servicenow.com/sp/en/apple-iphone-13?id=sc_cat_item&sys_id=ec80c13297968d1021983d1e6253af32&sysparm_catgory=1e80c15697969f1032083d1e6253be15`. |
[Table 7. Returns]

{#GSPUtil-getHumReadUrl_GR_SM__table_eht_dpg_hvb}  
The following code example shows how to obtain a specific KB article and call the
getHumanReaadableUrl() to apply the associated dynamic variables.

    function() {
      var spUtil = new GlideSPUtil();
      var pageGR = spUtil.getPageRecordWithPageRoute('kb_article', '81b75d3147032100ba13a5554ee4902b', false);
      var queryParams = RP.getParameters();
      var hrUrl = spUtil.getHumanReadableUrl(pageGR, queryParams);
    }

Output:

```

```


