---
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


---

# SPSEOUtilsSNC - Global

# SPSEOUtilsSNC - Global {#ariaid-title1}

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

The SPSEOUtilsSNC script include provides utility methods that return human-readable URLs for a specific page, or for the current page, based on the transaction request.

In addition, this API provides other utility methods that you can use to obtain information
that is needed to call other human-readable URL methods.

## SPSEOUtilsSNC - getHumanReadableUrl(GlideRecord pageGR, String queryString) {#ariaid-title2}

Returns the human-readable URL for a specified record in the Page \[sp_page \] table. Uses the passed-in query parameters to resolve any dynamic page variables required by the URL.
{#SPSU-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 for which to return the human-readable URL. Use the [SPSEOUtilsSNC - getPageRecordWithPageRoute(GlideRecord pageId, String portalId, Boolean preventReRoute)](https://servicenow-prod.fluidtopics.net/~GJyAm2ZXZDiVzJ2s6dGDQ#SPSU-getPageRecWPageRte_S_S_B "Returns the GlideRecord from the Pages [sp_page] table whose ID field matches the passed ID parameter (pageId). Call this method prior to calling the getHumanReadableUrl() method to obtain the desired sp_pages GlideRecord.") method to obtain the desired sp_page GlideRecord. |
| queryString | String | Query string to use to resolve any parameters that may need to be passed by the URL. For example: `?id=kb_article&sys_id=471ee81eff6002009b20ffffffffff34` |
[Table 1. Parameters]

{#SPSU-getHumReadUrl_GR_S__table_vjm_wwg_hvb} {#SPSU-getHumReadUrl_GR_S__table_wjm_wwg_hvb__entry__2}

| Type | Description |
|-|-|
| String | Human-readable URL for the specified Service Portal record. The URL variables are resolved using the contents of the passed queryString parameter. |
[Table 2. Returns]

{#SPSU-getHumReadUrl_GR_S__table_wjm_wwg_hvb}  
The following code example shows how to call this method to obtain the human-readable URL.

    function() { 
      var util = new global.SPSEOUtilsSNC();
      var portalId = util.getPortalId();
      var pageGR = util.getPageRecordWithPageRoute(
        'kb_article', portalId, false); 
      var queryString = "?id=kb_article&sys_id=471ee81eff6002009b20ffffffffff34"; 
      var hrUrl = util.getHumanReadableUrl(pageGR, queryString);

{#SPSU-getHumReadUrl_GR_S__codeblock_epr_kgh_vvb}

Output:

    "getting-around-in-windows"

## SPSEOUtilsSNC - getHumanReadableUrlForCurrentRequest() {#ariaid-title3}

Returns the human-readable URL for the current Service Portal
record.
This method replicates the parameters in the cryptic URL of the current page, such as the
id parameter and the query parameters, when creating this
human-readable URL.
{#SPSU-getHumanReadUrlForCurReq__table_cwl_4rp_tvb__entry__3}

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

{#SPSU-getHumanReadUrlForCurReq__table_cwl_4rp_tvb} {#SPSU-getHumanReadUrlForCurReq__table_dwl_4rp_tvb__entry__2}

| Type | Description |
|-|-|
| String | Human-readable URL for the current Service Portal record. |
[Table 4. Returns]

{#SPSU-getHumanReadUrlForCurReq__table_dwl_4rp_tvb}  
The following code example shows how to call this method. In this example, the current Service Portal record uses the cryptic URL of
`<instance-url>/sp?id=kb_article&sys_id=471ee81eff6002009b20ffffffffff34`
and is configured to show the short description of a KB article that discusses navigation in
Windows. The returned human-readable URL for this cryptic URL is
"getting-around-in-windows".

    // In a script include
    function() {
      var util = new global.SPSEOUtilsSNC()
      var hrUrl = util.getHumanReadableUrlForCurrentRequest();
    }

Output:

    getting-around-in-windows

## SPSEOUtilsSNC - getPageRecordWithPageRoute(GlideRecord pageId, String portalId, Boolean
preventReRoute) {#ariaid-title4}

Returns the GlideRecord from the Pages \[sp_page\] table whose ID field matches the
passed ID parameter (pageId). Call this method prior to calling the
getHumanReadableUrl() method to obtain the desired sp_pages
GlideRecord.
You can also request that the method use the page route maps information to return the
GlideRecord of the final Service Portal page associated with the passed Service Portal page ID. For additional information on page route maps, see
[Redirect a reference to a page
ID](https://www.servicenow.com/docs/access?context=reroute-page&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US).
{#SPSU-getPageRecWPageRte_S_S_B__table_hhx_rzn_tvb__entry__3}

| Name | Type | Description |
|-|-|-|
| pageId | String | ID of the Pages \[sp_page\] record to return. Located in the id field of the Pages \[sp_page\] table. |
| portalId | String | Sys_id of the associated Service Portal \[sp_portal\] record. Required to return the appropriate login or 404 pages in case the record associated with the passed pageId parameter is not accessible or unavailable. Use the [SPSEOUtilsSNC - getPortalId()](https://servicenow-prod.fluidtopics.net/~GJyAm2ZXZDiVzJ2s6dGDQ#SPSU-getPortalId "Returns the sys_id of the portal being loaded based on the portal suffix in the request URL. Call this method prior to calling the getPageRecordWithPageRoute() method to obtain the desired Service Portal sys_id.") method to obtain the desired Service Portal ID. |
| preventReRoute | Boolean | Flag that indicates whether to use page route maps to return the GlideRecord for the last sp_page that the passed page ID resolves to, instead of the matching sp_page record. Possible values: * true: Use the page route maps to return the last sp_page record that the passed page ID resolves to. * false: Return the sp_page record that the passed page ID matches. |
[Table 5. Parameters]

{#SPSU-getPageRecWPageRte_S_S_B__table_hhx_rzn_tvb} {#SPSU-getPageRecWPageRte_S_S_B__table_ihx_rzn_tvb__entry__2}

| Type | Description |
|-|-|
| GlideRecord | Record that matches the query request for the sp_page record. |
[Table 6. Returns]

{#SPSU-getPageRecWPageRte_S_S_B__table_ihx_rzn_tvb}  
The following code example shows how to call this method prior to calling the
getHumanReadableUrl() method.

    function() { 
      var util = new global.SPSEOUtilsSNC();
      var portalId = util.getPortalId();
      var pageGR = util.getPageRecordWithPageRoute(
        'kb_article', portalId, false); 
      var queryString = "?id=kb_article&sys_id=471ee81eff6002009b20ffffffffff34"; 
      var hrUrl = util.getHumanReadableUrl(pageGR, queryString);

## SPSEOUtilsSNC - getPortalId() {#ariaid-title5}

Returns the sys_id of the portal being loaded based on the portal suffix in the request
URL. Call this method prior to calling the getPageRecordWithPageRoute()
method to obtain the desired Service Portal sys_id.
{#SPSU-getPortalId__table_l5r_sxg_tvb__entry__3}

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

{#SPSU-getPortalId__table_l5r_sxg_tvb} {#SPSU-getPortalId__table_m5r_sxg_tvb__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the requested Service Portal based on the portal suffix of the request URL. |
[Table 8. Returns]

{#SPSU-getPortalId__table_m5r_sxg_tvb}  
The following code example shows how to call this method for a URL such as
`<instance-url>/sp?id=index`.

    function() { 
      var util = new global.SPSEOUtilsSNC();
      var portalId = util.getPortalId();
      var pageGR = util.getPageRecordWithPageRoute(
        'kb_article', portalId, false); 
      var queryString = "?id=kb_article&sys_id=471ee81eff6002009b20ffffffffff34"; 
      var hrUrl = util.getHumanReadableUrl(pageGR, queryString);

Output:

    81b75d3147032100ba13a5554ee4902b


