The CreatorCon Call for Content is officially open! Get started here.

Trying to get user via URL parm and getting "undefined"

Jason Stephens
Kilo Guru

I'm trying to use the "catalog" example from this post  https://community.servicenow.com/community?id=community_blog&sys_id=596dea29dbd0dbc01dcaf3231f96190b - exactly as it is - I need to grab the user sys id from a sysparm_user parameter I'm passing in a URL.  The only change to the example code is the variable name.  I am getting "undefined" for the user parm and I have no idea why.  I added code to grab the sys id of the cat item and it works.  Seems like a fairly simple script but I'm having no luck with it.  Thanks for any help!

 

URL - .....com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=e053fdc81b4285100eb20fa2cd4bcbe2&sysparm_user=b0e43ebf1b0081100eb20fa2cd4bcb0f

Works - var id = getParameterValue('sysparm_id');

alert("sysparm_id is " + id); //returns sys id of cat item
   

Does not work - var user = getParameterValue('sysparm_user');

alert("sysparm_user is " + user); //returns "undefined"

 

1 ACCEPTED SOLUTION

Jason Stephens
Kilo Guru

Solution!

I needed to use "%26" between parms instead of just the "&"

RIGHT - servicecatalog_cat_item_view.do?sysparm_id=e053fdc81b4285100eb20fa2cd4bcbe2%26

sysparm_user=b0e43ebf1b0081100eb20fa2cd4bcb0f

WRONG - servicecatalog_cat_item_view.do?sysparm_id=e053fdc81b4285100eb20fa2cd4bcbe2&sysparm_user=b0e43ebf1b0081100eb20fa2cd4bcb0f

View solution in original post

4 REPLIES 4

seanphelan
Tera Expert

Use a different var then user.  user might be a reserved word in ServiceNow

Good thought, but same result...

Jason Stephens
Kilo Guru

Good thought, but same result...

Jason Stephens
Kilo Guru

Solution!

I needed to use "%26" between parms instead of just the "&"

RIGHT - servicecatalog_cat_item_view.do?sysparm_id=e053fdc81b4285100eb20fa2cd4bcbe2%26

sysparm_user=b0e43ebf1b0081100eb20fa2cd4bcb0f

WRONG - servicecatalog_cat_item_view.do?sysparm_id=e053fdc81b4285100eb20fa2cd4bcbe2&sysparm_user=b0e43ebf1b0081100eb20fa2cd4bcb0f