- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 01:33 PM
Is there a way to find all the scripts in the system where sysIDs are hardcoded.
Any response is appreciated!!
Thanks,
Harshit
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 02:33 PM
Hi Harshit,
What a nice surprise to meet you on Community!
SNGuru solution works if you search for a specific sys_id. If you want to search for any hardcoded sys_id you can use a background script like this, using a regular expression.
var regexp = /[0-9a-f]{32}/; // Match any string made of 32 hexadecimal characters
var gr = new GlideRecord('sys_script'); // Replace this to check for other tables. This one is business rules
// gr.addQuery('sys_customer_update=true'); // Uncomment this if you want to exclude out-of-the-box scripts from ServiceNow
gr.query();
while (gr.next()) {
if (gr.script.match(regexp))
gs.print('Sys_id found in script: ' + gr.name);
}
I hope you are well since our last project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2020 05:07 AM
To the extend with the above code, I want to count no.of scripts also... but I dont want to use "getRowCount()"
I want to use glide Aggregate function...is it possible? or I just go with increment function?
due to performance issue I dont want to prefer getRowCount..
Could you please help

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 08:20 AM
The CodeSanity app contains a set of Instance Scan checks aimed at improving source code and application quality. Developers should run them before shipping a new application version.
Checking for scripts with hard-coded sys_ids is one of them.
Vote to make it part of the platform OOTB!
Or install it right away: