- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2021 04:01 PM
Hello
I would like to add values in my form using url but it doesn't work. I made a client script:
function onLoad()
{
var serviceinput = getParameterValue('sysparm_service');
if (varserviceinput)
{
g_form.setValue('category', 'service');
g_form.setValue('business_service', serviceinput);
}
}
function getParameterValue(name)
{
var url = document.URL.parseQuery();
if (url[name])
{
return decodeURI(url[name]);
} else
{
return;
}
}
But as soon as I open my catalog item I have a JavaScript error.
What am I doing that is not working? And how to call my url?
thank you very much
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2021 10:46 AM
You can use the script below as mentioned in the following post:
https://community.servicenow.com/community?id=community_blog&sys_id=ec3eea6ddbd0dbc01dcaf3231f9619d6
URL with parameter:
https://<instance name>.service-now.com/nav_to.do?uri=com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=d65394f54ff2520020af09fd0210c759&sysparm_user=2809952237b1300054b6a3549dbe5dd4
function onLoad() {
//Type appropriate comment here, and begin script below
var user = getParameterValue('sysparm_user');
if (user) {
g_form.setValue('descriptionTest', 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]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2021 07:33 AM
What error do you receive when you check the browser console log? What is it telling you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2021 07:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2021 10:46 AM
You can use the script below as mentioned in the following post:
https://community.servicenow.com/community?id=community_blog&sys_id=ec3eea6ddbd0dbc01dcaf3231f9619d6
URL with parameter:
https://<instance name>.service-now.com/nav_to.do?uri=com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=d65394f54ff2520020af09fd0210c759&sysparm_user=2809952237b1300054b6a3549dbe5dd4
function onLoad() {
//Type appropriate comment here, and begin script below
var user = getParameterValue('sysparm_user');
if (user) {
g_form.setValue('descriptionTest', 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]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2021 04:58 AM
ok i no longer have the javascript error but when i enter the url it redirects me not to the portal service but to the portal agent. How to go to the SP?
https://servicenow.domain/nav_to.do?uri=com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=b545558c1b47a0104426524f034bcbfc&sysparm_service=7279a98f1b16a8100e87caee034bcbbb