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.

SOW how to get url params

KelvinY2025
Tera Contributor
function onLoad() {
    // var url = new GlideURL(window.location.href);
    // var paramValue = url.getParam('myparam');
    // if (paramValue) {
    // console.log('Parameter exists with value:', paramValue);
    // } else {
    // console.log('Parameter does not exist.');
    // }
KelvinY2025_0-1764142711920.png

 


    var paramValue = getParameterByName('myparam');
    if (paramValue) {
    console.log('Parameter exists with value:', paramValue);
    } else {
    console.log('Parameter does not exist.');
    }


}


function getParameterByName(name) {
   var url = window.location.href;
   name = name.replace(/[\[\]]/g, '\\$&'); // Escape special characters
   var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
   var results = regex.exec(url);
   if (!results) return null;
   if (!results[2]) return '';
   return decodeURIComponent(results[2].replace(/\+/g, ' '));
}KelvinY2025_0-1764142614491.png

 

google AI cannot provide a client script method that can be used in SOW, who can give an example? 😂
0 REPLIES 0