We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Get sysparm value from URL in a list control

Goran WitchDoc
ServiceNow Employee

I have a list control for that I want to customize so if a specific sysparm(sysparm_nonew) appears in the url, I want to hide the new button.

But I can't find how get get the sysparm_nonew from the url. I tried "gs.action.getGlideURI().getMap().get('sysparm_nonew')" but will only return null no matter if I got sysparm_nonew=true eller not in the URL.

Any ideas?

//Göran

23 REPLIES 23

Ankur Bawiskar
Tera Patron

Hi Goran,



Are you doing this in client side


if yes then here is the code



var rec_sys = getParmVal('sysparm_nonew'); // this contains the value


if(rec_sys != null) {


alert(rec_sys);


}



function getParmVal(name){


  var url = document.URL.parseQuery(); // this gives the window url


  if(url[name]){


  return decodeURI(url[name]);


  }


  else{


  return;


  }


}



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

As I'm writing about, I'm doing this in a list control. So it's server side.



//Göran


Ankur Bawiskar
Tera Patron

Hi Goran,



These links would be helpful:


How To Get Parameters/Values From a URL in ServiceNow | SN Commander


Finding the sys_id of a record — ServiceNow Elite



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hmm..I think I know what the problem is thou. If I use like "gs.action.getGlideURI().toString()" I get -> api/now/v2/ui/init_list/change_request?api=api and not the "real URL"... that is why my other first test didn't work either with gs.action.