diff --git a/Server-Side Components/Background Scripts/Report Ownerships/readme.md b/Server-Side Components/Background Scripts/Report Ownerships/readme.md new file mode 100644 index 0000000000..8210494333 --- /dev/null +++ b/Server-Side Components/Background Scripts/Report Ownerships/readme.md @@ -0,0 +1,2 @@ +Consider a case where users who had created reports are no longer part of the organization i.e. are Active=False, however the reports needs to be edited to make it useful further. How about getting this worked by updating the ownership of report from backend. +Use script attached as background script to update the ownership of reports. diff --git a/Server-Side Components/Background Scripts/Report Ownerships/script.js b/Server-Side Components/Background Scripts/Report Ownerships/script.js new file mode 100644 index 0000000000..81bc6eeb89 --- /dev/null +++ b/Server-Side Components/Background Scripts/Report Ownerships/script.js @@ -0,0 +1,8 @@ +var grReport = new GlideRecord('sys_report_users_groups'); +grReport.getEncodedQuery('user_id.nameLIKEJaspal');//replace the query correctly for the reports that requires ownership change +grReport.query(); +while (grReport.next()) { + grReport.user_id = "20db787ec374bd58265fdf3c05011234"; //replace sys_id with relevant sys_id of the user who will have the ownership updated to + grReport.autoSysFields(false); + grReport.update(); +}