- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2024 01:50 AM
Hi
I am trying to serach for querying against 'sys_object_source' table in all the script fields in the instance. But the above code is not working please help me.
Help me to provide how to keep correct regular expressions.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2024 02:04 AM
O really small though essential typo I made, here is working tested code:
(function (engine) {
// Remove code comments
var commentsRegEx = /\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm;
var commentsRemovedValue = engine.columnValue.replace(commentsRegEx, '');
var search_regex = /\bGlideRecord\(['"]sys_object_source['"]\)/gm;
// Create scan finding
if(search_regex.test(commentsRemovedValue)) {
engine.finding.increment();
}
})(engine);
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2024 05:45 AM
Did you apply the second script I shared? Looking at your results, you didn't and you applied the first script I shared.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-17-2024 11:23 PM
I tried the given code by you, but i am not getting correct findings:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-17-2024 11:49 PM
I tested the second code I shared and am getting the correct/expected findings. So question is, what is your definition of not getting the correct findings? What would you have expected? What are you now getting? Please describe this clearly.
Can you use Linter Check also? Don't know, haven't tried for such a case yet. You can check for GlideRecord occurrence, though if you can then also check for the table name, I haven't tried. Maybe you can try and share that knowledge š
Please also handle your other open questions. Reply, mark answers as helpful, mark an answer as correct if it was solved.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-17-2024 11:55 PM
I checked of the some of the script fields in script includes in that so many records(min 10records) contain query on sys_object_source table. but by using your code i am getting only 2findings.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-18-2024 12:01 AM
Can you share examples? And are all of those records custom? Or out-of-the-box?
It might also well be that the scripting notation in those records is a minor bit different, so perhaps the regex needs to be expanded. Though for that you need to share examples.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field