- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 03:00 AM
Hi there,
I have a requirement where I need to create Catalog Item 1 (considered the parent) with two variables: Manager and Employee.
Once Catalog Item 1 is submitted (ordered), it should trigger an email notification to the Manager. In the body of the email, there will be a link to Catalog Item 2.
When the Manager clicks this link and Catalog Item 2 form loads, the same two variables (Manager and Employee) on Catalog Item 2 should automatically populate with the values submitted in Catalog Item 1.
I'm not exactly sure how to implement the value passing and auto-population. Could you please guide me on how to set this up?
thanks
priya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 03:39 AM
1. First build the custom URL format as required and use that in the email notification
Syntax:
https://<INSTANCE-ID>.service-now.com/sp?id=sc_cat_item&sys_id=<CAT ITEM SYS ID>&<VARIABLE 1>=<VALUE 1>&<VARIABLE 2>=<VALUE 2>
Ex:
2. Create On-Load as below to map the URL parameters to the catalog itm variables.
function onLoad() {
var manager_url = getParameterValue('manager'); // URL PARATMETER
var employee_url = getParameterValue('employee'); // URL PARATMETER
if (manager_url) {
g_form.setValue('manager', manager_url); // SETTING CAT VARIABLE
}
if (employee_url) {
g_form.setValue('employee', employee_url); // SETTING CAT VARIABLE
}
}
function getParameterValue(name) {
var url = top.location.href;
var value = new URLSearchParams(url).get(name);
if (value) {
return value;
}
}
Regards
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 04:40 AM
if you are using flow designer then check my blog on how to add link and in that LINK to 2nd catalog item include the variable values for both the variables, then use onLoad catalog client script on 2nd item to get the values from URL and populate them
ServiceNow Flow Designer: Adding Record Link in "Send Email" flow action
1) form the URL like this /sp?id=sc_cat_item&sys_id=catItemSysId2&sysparm_manager=<flowVariableManager>&sysparm_employee=<flowVariableEmployee>
2) onLoad catalog client script
function onLoad() {
try {
var url = top.location.href;
if (window == null) {
// for portal
var manager = new URLSearchParams(url).get("sysparm_manager");
var employee = new URLSearchParams(url).get("sysparm_employee");
g_form.setValue('managerVariable', manager);
g_form.setValue('employeeVariable', employee);
}
} catch (ex) {
// for native
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var manager1 = gUrl.getParam("sysparm_manager");
var employee1 = gUrl.getParam("sysparm_employee");
g_form.setValue('managerVariable', manager1);
g_form.setValue('employeeVariable', employee1);
}
}
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
05-05-2025 04:40 AM
if you are using flow designer then check my blog on how to add link and in that LINK to 2nd catalog item include the variable values for both the variables, then use onLoad catalog client script on 2nd item to get the values from URL and populate them
ServiceNow Flow Designer: Adding Record Link in "Send Email" flow action
1) form the URL like this /sp?id=sc_cat_item&sys_id=catItemSysId2&sysparm_manager=<flowVariableManager>&sysparm_employee=<flowVariableEmployee>
2) onLoad catalog client script
function onLoad() {
try {
var url = top.location.href;
if (window == null) {
// for portal
var manager = new URLSearchParams(url).get("sysparm_manager");
var employee = new URLSearchParams(url).get("sysparm_employee");
g_form.setValue('managerVariable', manager);
g_form.setValue('employeeVariable', employee);
}
} catch (ex) {
// for native
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var manager1 = gUrl.getParam("sysparm_manager");
var employee1 = gUrl.getParam("sysparm_employee");
g_form.setValue('managerVariable', manager1);
g_form.setValue('employeeVariable', employee1);
}
}
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