How to set a default value to a Variable by judging a URL-parameter

iwasaki
Tera Contributor

We make our support page by the Record Producer.
I want to set a different default value to a Variable per URL-parameter.

 

It is possible to judge a URL-parameter in a Catalog Client Script. But I need that in server-side(=Variable's Default Value).

It seems that it was possible before, but is it possible to implement it now?
Please tell me how if possible.

ss.png

1 ACCEPTED SOLUTION

AnubhavRitolia
Mega Sage
Mega Sage

Hi @iwasaki 

 

Please try below code in Default Value:

 

javascript: gs.action.getGlideURI().getMap().get('sysparm_aparameter'); // 'sysparm_aparameter' will be replaced by your URL parameter

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

View solution in original post

4 REPLIES 4

AnubhavRitolia
Mega Sage
Mega Sage

Hi @iwasaki 

 

Please try below code in Default Value:

 

javascript: gs.action.getGlideURI().getMap().get('sysparm_aparameter'); // 'sysparm_aparameter' will be replaced by your URL parameter

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Thank you for your reply. I appreciate it very much😀
I have able to get a URL-parameter by that script.
(But I don't use "getMap()"... gs.action.getGlideURI().get("parameter");)

Ankur Bawiskar
Tera Patron
Tera Patron

@iwasaki 

you can use gs.action.getGlideURI() in default value using script but I would suggest to use onLoad client script and get the url parameter value and then set the value

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Thank you for your reply.
I have able to get a URL-parameter by using "gs.action.getGlideURI().get()".

 


I would suggest to use onLoad client script

 

 

I wish I could in onLoad. But the target Variable has onChange.
Because I don't want the onChange to work, I wanted to implement it on the server side.