- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2022 02:24 AM
Hi everyone,
I want to get all the duplicate names (same name for two or more records) for script includes. Like in an instance if there are 5403 script includes (active ones), then I want to know all the duplicate names of the script includes. Can someone help me here
Regards,
Pallavi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2022 02:32 AM
Hello Pallavi,
Can you try executing below script in background script
I am pushing them into an array and printing the array
var arr=[]
var gr = new GlideRecord('sys_script_include');
gr.query();
while(gr.next())
{
var dup = new GlideRecord('sys_script_include');
dup.addQuery('name',gr.name);
dup.addQuery('sys_id','!=',gr.sys_id);
dup.query();
while(dup.next())
{
if(arr.indexOf(dup.name.toString())==-1)
{
arr.push(dup.name.toString());
}
}
}
gs.print(arr);
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2022 02:32 AM
Hello Pallavi,
Can you try executing below script in background script
I am pushing them into an array and printing the array
var arr=[]
var gr = new GlideRecord('sys_script_include');
gr.query();
while(gr.next())
{
var dup = new GlideRecord('sys_script_include');
dup.addQuery('name',gr.name);
dup.addQuery('sys_id','!=',gr.sys_id);
dup.query();
while(dup.next())
{
if(arr.indexOf(dup.name.toString())==-1)
{
arr.push(dup.name.toString());
}
}
}
gs.print(arr);
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2022 02:42 AM
Thank you Mohit. It's working
Have a nice time 🙂
Regards,
Pallavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2022 02:32 AM
Hi
just having a look on the name of a Script Include is not helpful, as each Script Include has a namespace (global or custom scope) and only the combination of namespace and name of the Script Includes makes it unique.
Therefore checking the "API Name" is the better approach.
Kind Regards
Maik