How to Get paremeter value from public survey url
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a req for adding the read only question User Name to a public survey. the value of User Name need to get from URL. how to implement it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @JackieZhang ,
You can use the below logic to get the user name and then you can add your own code if you want to set it to a particular field or anything else.
var gUrl = top.location.href; //getting the URL
//fetch the parameter from url, add the replace the param_name with your parameter name.
var uName = new URLSearchParams(gUrl).get("param_name");
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Sorry, where do I need to add it to?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@JackieZhang This is a scipt to fetch the value. This can directly be used in a client script.
I saw the url that you gave as a reply. In the reply you are sending the user name as 'name' (name=jackie).
In the script I gave, replace "param_name" with "name".
After doing so, add one line for setValue for setting the field you want to the 'name' parameter's value. Below is an example
g_form.setValue('your_field_backend_name', uName);
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
where is the user taking survey? portal or native?
share screenshots
what's your actual business requirement?
check this
Setting value of survey question via client script
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
