- 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
06-07-2017 01:37 PM
SNGuru has a nice solution: https://www.servicenowguru.com/system-definition/find-references-specific-record/
- 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
06-08-2017 06:59 AM
Hi Shiva,
Indeed!! Good to hear from you as always and thank you for your reply. Works like a charm
Best regards,
Harshit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2020 04:59 AM
To the extend of the above code, I want to count no.of scripts also... without using "RowCount"
I want to glide Aggregate function