- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 07:57 AM
Hello all, I would like to ask how I can create a work note about removed record. For example in my case I would like create a work note of removed change task in change request log if possible with the number of that deleted record. But I do not know if it is even possible to do such a thing.
I need it because customer is using third party tool to synchronize records between our Servicenow instance and their ITSM tool and they do not want to enable possibility of removal any value even in the initial(NEW) state of the record.
Anyway I will be glad for any links hint or confirmation, that this is not an option in Servicenow or it is not worth it to create such a thing.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 08:17 AM - edited 10-14-2024 08:18 AM
Hi @Miloslav1
You need to write before-delete Business rule on change_task table to achieve this requirement. You can use below script for same,
(function executeRule(current, previous /*null when async*/ ) {
var changeRequest = current.change_request.getRefRecord();
if (changeRequest.isValidRecord()) {
// Add a work note to the associated change request
var workNoteMessage = "Change Task '" + current.number + "' has been deleted.";
changeRequest.work_notes = workNoteMessage;
changeRequest.update();
}
})(current, previous);
This will definitely helps you to resolved your issue. Let me know in case you need anything else, you can DM on LinkedIn.
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Best Regards,
Krushna Birla
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 08:05 AM - edited 10-14-2024 08:16 AM
Hi @Miloslav1
Yes it is possible
Create BR on Change Task Table ( Before -> Delete)
In script Section get Change Request number associated to change Task and update Change Request
var gr = new GlideRecord('change_request');
if (gr.get(current.change_request)) {
gr.work_notes = 'Deleted Change Task ' + current.number.toString();
gr.update();
}
Please mark this response as Correct and Helpful if it helps you can mark more that one reply as accepted solution.
Thanks
Esh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 08:17 AM - edited 10-14-2024 08:18 AM
Hi @Miloslav1
You need to write before-delete Business rule on change_task table to achieve this requirement. You can use below script for same,
(function executeRule(current, previous /*null when async*/ ) {
var changeRequest = current.change_request.getRefRecord();
if (changeRequest.isValidRecord()) {
// Add a work note to the associated change request
var workNoteMessage = "Change Task '" + current.number + "' has been deleted.";
changeRequest.work_notes = workNoteMessage;
changeRequest.update();
}
})(current, previous);
This will definitely helps you to resolved your issue. Let me know in case you need anything else, you can DM on LinkedIn.
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Best Regards,
Krushna Birla

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 08:22 AM
You would need to write a before BR on the change_task table with the operation "delete". your code will look something like this -
(function executeRule(current, previous /*null when async*/) {
var changeRequest = new GlideRecord('change_request');
if (changeRequest.get(current.change_request)) {
changeRequest.work_notes = "The change task that got deleted is - " + current.number; // Verbiage can change.
changeRequest.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 02:43 AM
Thank you very much all for quick help. It is working!