Igor Kozlov
Tera Expert
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 10-23-2020 07:54 AM
I some of your changes are not scoped or you need to find creator of some old old you will step on the problem: Created By field is actually showing the user who applied the update set, not one who modified the script.
My suggestion is no add a calculated Blame! field to your sys_update_version and sys_update_xml tables.
The code it pretty simple:
(function calculatedFieldValue(current) {
return findLastUpdater(current);
})(current);
//current - sys_update_version or remote update
function findLastUpdater (current){
var xmlString = current.getValue('payload');
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(xmlString);
var userName = xmlDoc.getNodeText('//sys_updated_by');
if(!userName) return ""; //reasonable on upgrade and some edge cases
//modify if you would like to use String, email, etc instead of reference
var gr = new GlideRecord('sys_user');
gr.get('user_name', userName );
return gr.getUniqueValue();
};
See result at screenshot - script was always changed by same person, even Created by show 3 different users