- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 07:45 AM
Hello Developers,
I have a requirement where an RITM is created from an Incident using the 'Relates Search Results' functionality. From there, users can search for a Service Requester and click on ‘Order’, which redirects them to the catalog item using the servicecatalog_cat_item_view form.
In this context, I’d like to auto-populate the field what_is_source_of_exception_requirement on the catalog item with the incident number (i.e., the parent record of the RITM).
Here’s the URL being used:
com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=8ea574d297a62290cbf4b976f053af12&sysparm_view=catalog_default&sysparm_parent_table=incident&sysparm_parent_sys_id=096777069726ee50cbf4b976f053af57
I attempted this via a client script, but it doesn’t seem to work—likely because client scripts can’t access server-side data like the incident number directly using GlideRecord.
Could you please advise if this can be achieved, and if so, what would be the recommended approach?
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 12:37 AM
I already informed to use GlideAjax and query INC table and get number
Another way is to use GlideRecord with callback
Something like this
function onLoad() {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var incSysId = gUrl.getParam("sysparm_parent_sys_id");
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', incSysId);
gr.query(checkRecord);
function checkRecord(gr) {
if (gr.next()) {
g_form.setValue('what_is_source_of_exception_requirement', gr.number);
}
}
}
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
07-08-2025 12:11 AM
you should include INC number and not sysId since your variable is string type
use this onLoad catalog client script
If you can't pass INC number then once you get sysId then you can use GlideAjax to query incident with that sysId and get INC number and then set it
function onLoad() {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var incNumber = gUrl.getParam("sysparm_parent_sys_id");
g_form.setValue('what_is_source_of_exception_requirement', incNumber);
}
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
07-08-2025 12:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 12:36 AM
@Naveen87, you need to make ajax call to get Incident Number. Please refer above solution provided.
Please mark this response as Correct and Helpful if it assists you. You can mark more than one reply as an accepted solution.
Thanks,
Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 12:37 AM
I already informed to use GlideAjax and query INC table and get number
Another way is to use GlideRecord with callback
Something like this
function onLoad() {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var incSysId = gUrl.getParam("sysparm_parent_sys_id");
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', incSysId);
gr.query(checkRecord);
function checkRecord(gr) {
if (gr.next()) {
g_form.setValue('what_is_source_of_exception_requirement', gr.number);
}
}
}
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
07-08-2025 12:45 AM