- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 03:42 PM
I have a UI Action and an onLoad Catalog Client Script that needs to auto-populate variables from a record to the Catalog Item form.
This is working but I can't seem to get the code right for the Reference fields to Account and Ticket #
How it should work:
From a saved record, click the UI Action that directs to the Catalog Item (I have this working) > the Catalog Item needs to be auto-populated with the following fields from the record:
Account name
Ticket #
Can someone please help by providing examples of how I can get this to work?
Any help is greatly appreciated!!
Thank you,
Susam
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 11:38 AM
You can use the above logic if it is in service portal but for the native UI, you can make use of the below function:
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return "";
}
}
(=tested)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 04:44 PM
@Su522 Please check this.
https://www.servicenow.com/community/itsm-forum/fill-catalog-variable-via-url/m-p/2748704
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 05:06 PM
Hello @Su522
Try the below script:
function onLoad() {
//Type appropriate comment here, and begin script below
var inc = getParameterValue("sysparm_incident"); //replace with your parm's
if (inc) {
g_form.setValue("incident", inc); //replace with your variable name
}
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]);
}
}
}
(=tested)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2024 07:34 AM - edited 10-24-2024 10:16 AM
Thank you Murthy, I appreciate your response but I haven't been able to get this to work.
Maybe I'm updating the code wrong?
Here is my code for the Catalog Client Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2024 11:38 AM
You can use the above logic if it is in service portal but for the native UI, you can make use of the below function:
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return "";
}
}
(=tested)
Murthy