Skip to content

Commit f988e5a

Browse files
Create code.js
1 parent 47086c2 commit f988e5a

File tree

1 file changed

+35
-0
lines changed
  • Server-Side Components/Script Includes/Script Include Usage Tracker

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
3+
var scriptIncludeName = 'MyScriptInclude'; // Change this to your target Script Include
4+
var usage = [];
5+
6+
function searchUsage(table, field) {
7+
var gr = new GlideRecord(table);
8+
gr.addEncodedQuery(field + 'LIKE' + scriptIncludeName);
9+
gr.query();
10+
while (gr.next()) {
11+
usage.push({
12+
table: table,
13+
name: gr.name || gr.getDisplayValue(),
14+
sys_id: gr.getUniqueValue()
15+
});
16+
}
17+
}
18+
19+
var tablesToSearch = [
20+
{ table: 'sys_script', field: 'script' },
21+
{ table: 'sys_ui_action', field: 'script' },
22+
{ table: 'sys_script_include', field: 'script' },
23+
{ table: 'sys_flow_context', field: 'definition' },
24+
{ table: 'sys_trigger', field: 'script' }
25+
];// can add more entries here
26+
27+
tablesToSearch.forEach(function(t) {
28+
searchUsage(t.table, t.field);
29+
});
30+
31+
gs.info('Usage of Script Include: ' + scriptIncludeName);
32+
usage.forEach(function(u) {
33+
gs.info('Found in table: ' + u.table + ', name: ' + u.name + ', sys_id: ' + u.sys_id);
34+
});
35+

0 commit comments

Comments
 (0)