not able to set the URL value in catalog item due to '&' as it is considering it as seperator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 04:50 AM
Hi All,
I am trying to get the values through an URL and put them on different fields in a catalog item. In the same process a field where value/Text should be set as 'Marketing & specialist' . I am only getting 'Marketting' and rest is missing as i believe it is considering '&' as seperator. So in URL instead of '&' it's showing '%26'.
Here is my script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 04:58 AM
try this
function onLoad() {
var url = top.location.href;
var params = new URLSearchParams(url.split('?')[1]);
var name = decodeURIComponent(params.get("sysparm_employeename"));
var manager = decodeURIComponent(params.get("sysparm_manager"));
var department = decodeURIComponent(params.get("sysparm_department"));
var title = decodeURIComponent(params.get("sysparm_title"));
var startdate = decodeURIComponent(params.get("sysparm_startdate"));
var reqID = decodeURIComponent(params.get('sysparm_sys_id'));
var worklocation = decodeURIComponent(params.get("sysparm_location"));
var dt = startdate.split(' ')[0];
g_form.setValue('employeename', name);
g_form.setValue('manager', manager);
g_form.setValue('department', department);
g_form.setValue('job_title', title);
g_form.setValue('start_date', dt);
g_form.setValue('work_location', worklocation);
g_form.setValue('reqnumber', reqID);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:11 AM
Hi Ankur,
Appreciate your quick response, i have checked it but it's giving 'null'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:20 AM
what came in alert for those individual values? none of the values came?
Did you see that?
where are you testing this? portal or native?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:28 AM
Yes, i checked alert as well and it came as blank. None of the values came. And it's native.