Pls advise how to get current record sys_id into scriptinclude
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 12:46 AM
Hi,
Please advise to get sysid of current location value into script include.
I am fetching location name from current record (UI action) and passing to script include.
UI Action:
Script Include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 01:07 AM - edited 07-14-2025 01:08 AM
I think your Script Include needs to query using name, not sys_id:
getlocation: function() {
var locationName = this.getParameter('sysparm_value');
var locationGR = new GlideRecord('cmn_location');
locationGR.addQuery('u_active', true);
locationGR.addQuery('name', locationName);
locationGR.query();
if (locationGR.next()) {
return locationGR.getUniqueValue(); // returns sys_id
}
return '';
}
Please mark correct/helpful if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 01:09 AM
is name field on form a string?
if yes then you need to query location table with that name and then get sysId
please share some screenshots and what's your requirement
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-14-2025 01:14 AM
i need to fetch current location record sysid then i pass it to Script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 01:59 AM
sorry but you didn't these 2 questions which I posted in my earlier response
-> is name field on form a string?
-> please share some screenshots and what's your requirement
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader