- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 10:33 AM
Hello,
I am trying to figure out an easy way of finding whether scripts were modified or not. Things like Business Rules, Client Scripts, UI Pages, etc...
Any pointers would be awesome!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 06:40 PM
You could query all customization records that
-Have NO Version (sys_version) record
OR
-No Versions records created by users that exist in the system
You would have to run it in Production as some version information isn't kept when your clone.
However, I came up a quick script based on that theory.
It assumes that:
- Your user names don't and have never changed
- All records that were created by a user that does not exist in the system is OOB.
- Records modified by a user that can be found in the system is a 'customisation'
Run this as a background script.
var tables = [ //customisation tables here
'sys_script_include',
'sys_ui_action',
'sys_script',
'sys_script_client',
'sysauto_script',
'sys_properties',
'sysevent_script_action',
'sys_ui_policy',
'sys_data_policy2'
];
var length = tables.length;
while (length--) { //Loop through each table
GetModifiedAssetsForTable(tables[length]);
}
function GetModifiedAssetsForTable(table) {
var gr = new GlideRecord(table);
gr.addJoinQuery('sys_user','sys_updated_by','user_name'); //We only want records updated by users in our system
gr.addQuery('sys_updated_by','!=','admin'); //admin account exists and this stuffs up our search
gr.query();
gs.print('***Searching ' + gr.getClassDisplayValue());
while (gr.next()) {
var grUser = new GlideRecord('sys_user');
grUser.addQuery('user_name', gr.sys_created_by );
grUser.query();
if (!grUser.next() ) { //Created by user is not in system (OOB asset)
var msg = gs.getMessage(
"{4} - {0} \r\n\ Created by:\t '{1}'\r\n Modified by:\t {2}\r\n Link: \t {3}",
[gr.getDisplayValue(), gr.sys_created_by, gr.sys_updated_by, gr.getLink(), gr.getClassDisplayValue()]
);
gs.print(msg);
}
}
}
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 10:43 AM
Hi Justin,
As far as I know there is not easy way. You have to go to each individual component for ex : Client Scripts and then sort based on created by and updated by field and then open each record and then find the difference based on the version history.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 10:50 AM
Could I use the criteria that if there is no version history, it has not been edited? How could I query for that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 11:36 AM
Hi Justin,
What is the specific use-case here? Are you trying to figure out what has been customized because of an upcoming Upgrade? Or because you think there have been modifications you aren't aware of? Is there nefariousness implicated?
There are a couple of places to look:
Look in sys_update_xml. Entries there are what the upgrade mechanism uses to determine if a file will be overwritten on upgrade or not. If someone made modifications and then deleted the entry from here, then you won't keep that modification through an upgrade.
Look in sys_update_version. Entries where the source is not "System Upgrades:somethingsomething" generally indicate a change was made by a user or via an applied Update Set, though I am not sure how Plugin activations that replace an existing script with a new version appear in this list.
Depending on your use case, this might be exactly what you need, or could be overkill. Why do you need the information?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 12:13 PM
use case is for upgrade purposes/generally having an idea of what all could potentially be causing issues within the instance