Find sys_id vaues in scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 07:48 AM - edited 02-04-2025 08:14 AM
Hi,
I have this regex (below) that works to match a sys_id value.
How do I search different various scripts (Script Includes, Business Rules, UI Action, client Script, etc) using this regex? (I can't figure out the syntax using 'new RegExp()' ...or, is there another way?)
Thanks in advance,
SM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 08:04 AM
Okay , if you are looking for a sys_id value that is hardcoded in any script, then in stead of a regex, you can basically do a global search against all the tables across application in servicenow studio.
- Just open the studio and switch to any application that allows to edit it, for example any workspace related applications.
- And then use the code search feature over there and make sure to check the checkbox on search on all applications.
Let me know if this helps.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 08:18 AM - edited 02-04-2025 08:19 AM
Hi,
I'm looking for ALL hardcoded sys_id values (32 alphanumeric characters) and not a specific sys_id or the code "sys_id" in the script.
My plan is to convert those sys_id values and store them in sys_properties table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 09:36 AM
Okay then in that case, i don't think there's an easier way to do it, you will have to run your reg exp against the scripts present in different records such as BRs, Script includes, client scripts etc.
That's why its important not to hardcode any sys_id rather storing them in a system property is a better way to go about it since its a lot easier to handle and manage.
Please mark this as helpful if you can.
Thanks!