- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-15-2022 03:42 AM
I was designing the virtual agent topic with some components once the user provides the inputs we need to present the catalog item with prepopulated fields
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-15-2022 09:43 AM
Hi All,
Thanks a lot for the support
This below code is working :
function onLoad() {
//Use the 'getParameterValue' function below to get the parameter values from the URL
var user = getParameterValue('sysparm_user');
if (user) {
g_form.setValue('user_variable', user);
}
}
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
***********************to fetch multiple values***************************
function onLoad() {
//Use the 'getParameterValue' function below to get the parameter values from the URL
var user = getParameterValue('sysparm_company');
var user1 = getParameterValue('sysparm_email');
if (user) {
g_form.setValue('company', user);
}
if (user1) {
g_form.setValue('email', user1);
}
}
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-15-2022 03:51 AM
Hi
it is described on page https://community.servicenow.com/community?id=community_blog&sys_id=596dea29dbd0dbc01dcaf3231f96190b
And a complete solution is provided on https://snprotips.com/blog/2019/4/4/set-catalog-variables-from-url-params-free-tool
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-15-2022 07:09 AM
Hi Maik,
Thanks for the prompt Response i tried all the above links which you have shared but no luck please see below screen shots for the reference
i done the same as per the link which you provided
https://dev45608.service-now.com/sp?id=sc_cat_item&sys_id=27b778a4075e4110b627f9fc7c1ed015&sysparm_variables={"company":"xyz"}
company is the backend value of catalog item please help
Regards,
Sai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-15-2022 07:12 AM
Something like this in URL
https://dev45608.service-now.com/sp?id=sc_cat_item&sys_id=27b778a4075e4110b627f9fc7c1ed015&sysparm_company=xyz
I hope you must have written onLoad catalog client script to fetch the url parameter and set it
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-15-2022 07:21 AM