Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

URLSearchParams and custom Service Catalog URL parameters with sysparm_ prefix

GLewis5
Tera Guru

I have seen a lot posts regarding the use of URLSearchParams in Catalog Client Scripts to extract custom parameter values from a URL. In all the examples, the names of the custom parameters start with "sysparm_".  As best I can tell, this prefix is not required when introducing a custom URL parameter. Why does everyone use a "sysparm_" prefix?

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hello @GLewis5 

 

Exactly, one doesn't need to use sysparm. PFB below example - 

 

    //Use the 'getParameterValue' function below to get the parameter values from the URL   
var par = getParameterValue('name of paramter in URL');

function getParameterValue(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(top.location);  
    if (results == null) {
        return "";
    } else {
        return unescape(results[1]);
    }
}

  

View solution in original post

1 REPLY 1

Community Alums
Not applicable

Hello @GLewis5 

 

Exactly, one doesn't need to use sysparm. PFB below example - 

 

    //Use the 'getParameterValue' function below to get the parameter values from the URL   
var par = getParameterValue('name of paramter in URL');

function getParameterValue(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(top.location);  
    if (results == null) {
        return "";
    } else {
        return unescape(results[1]);
    }
}