SPSEOUtilsSNC - Global

  • リリースバージョン: Australia
  • 更新日 2026年03月12日
  • 所要時間:9分
  • 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)

    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.

    表 : 1. Parameters
    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) 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

    表 : 2. Returns
    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.

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

    Output:

    "getting-around-in-windows"

    SPSEOUtilsSNC - getHumanReadableUrlForCurrentRequest()

    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.

    表 : 3. Parameters
    Name Type Description
    None
    表 : 4. Returns
    Type Description
    String Human-readable URL for the current Service Portal record.

    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)

    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.

    表 : 5. Parameters
    Name Type Description
    pageId String ID of the Pages [sp_page] record to return.

    Table: 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() 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.
    表 : 6. Returns
    Type Description
    GlideRecord Record that matches the query request for the sp_page record.

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

    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.

    表 : 7. Parameters
    Name Type Description
    None
    表 : 8. Returns
    Type Description
    String Sys_id of the requested Service Portal based on the portal suffix of the request URL.

    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