- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 04:39 AM
Hello Experts,
My requirement is
Example A user created 120 reports but he/she left organization now B user is joined that person replacement .
Now B user need to access all the reports which all are created by A user.
How can we change created by for all the reports.
Thanks in advance
Best Regards,
Raj
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 05:35 AM
Hey Raj,
Yes, you can use the provided script to update the "created_by" field for multiple records in the "sc_report" table. However, please note that updating the "created_by" field directly may lead to data integrity issues and is not recommended in most scenarios.
The "created_by" field in ServiceNow is a system field that tracks the user who originally created the record. Modifying this field manually may violate data integrity and auditing principles, as it could lead to incorrect information and make it difficult to trace the actual creator of the records.
var ReportOwnershipTransfer = Class.create();
ReportOwnershipTransfer.prototype = {
transferReports: function (A_USER_ID, B_USER_ID) {
var records = new GlideRecord('sc_report');
records.addQuery('created_by', A_USER_ID);
records.query();
while (records.next()) {
records.setValue('created_by', B_USER_ID);
records.update();
}
},
type: 'ReportOwnershipTransfer'
};
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 05:35 AM
Hey Raj,
Yes, you can use the provided script to update the "created_by" field for multiple records in the "sc_report" table. However, please note that updating the "created_by" field directly may lead to data integrity issues and is not recommended in most scenarios.
The "created_by" field in ServiceNow is a system field that tracks the user who originally created the record. Modifying this field manually may violate data integrity and auditing principles, as it could lead to incorrect information and make it difficult to trace the actual creator of the records.
var ReportOwnershipTransfer = Class.create();
ReportOwnershipTransfer.prototype = {
transferReports: function (A_USER_ID, B_USER_ID) {
var records = new GlideRecord('sc_report');
records.addQuery('created_by', A_USER_ID);
records.query();
while (records.next()) {
records.setValue('created_by', B_USER_ID);
records.update();
}
},
type: 'ReportOwnershipTransfer'
};
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar