Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

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

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