- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2023 03:35 AM
I want to update or delete the previous comments in the activity log of the incident form using scripting.
Also, need to create a "Redact" button so onclick Redact we can update or delete the comments on the incident form.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2023 10:51 PM
I need to do it using scripting, and also need to create a button for that on incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2023 10:51 PM
I need to do it using scripting, and also need to create a button for that on incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 04:20 AM
For update and delete the comments from the activity log I used the following script which works for me.
// Delete History Sets
var historyGR = new GlideRecord('sys_history_set');
historyGR.addEncodedQuery('id=' + currentRecord + '^ORid=' + requestItem);
historyGR.query();
historyGR.deleteMultiple();
// Update the current record
grRecord.update();
// Redact audit
var commentsGR = new GlideRecord('sys_audit');
commentsGR.addEncodedQuery('documentkey=' + currentRecord + '^ORdocumentkey=' + requestItem);
commentsGR.query();
while (commentsGR.next()) {
var comments, comments1;
if (commentsGR.fieldname == 'work_notes' || commentsGR.fieldname == 'comments') {
comments = commentsGR.newvalue;
} else {
comments = commentsGR.oldvalue;
}
comments1 = commentsGR.newvalue;
if (comments.indexOf(redactString) !== -1 || comments1.indexOf(redactString) !== -1) {
var updatedComments = comments1.replaceAll(redactString, '[REDACTED]');
commentsGR.newvalue = updatedComments;
if (commentsGR.fieldname != 'work_notes' && commentsGR.fieldname != 'comments') {
commentsGR.oldvalue = '';
}
commentsGR.autoSysFields('false');
commentsGR.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2023 03:42 AM
Hello @AishwaryaS1 ,
You can delete comments on any form by below links
* Journal Entry : https://instance-name.service-now.com/sys_journal_field_list.do?sysparm_query=element_id=sys_id of record
* Audit Entry : https://instance-name.service-now.com/sys_audit_list.do?sysparm_query=documentkey=sys_id of record
* History Set : https://instance-name.service-now.com/sys_history_set_list.do?sysparm_query=id=sys_id of record
* Email Entry : https://instance-name.service-now.com/sys_email_list.dosysparm_query=instance=sys_id of record
You can delete entries from here, also you can try to call it in UI action for delete it on button.
Kindly mark correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2023 10:51 PM
I need to do it using scripting, and also need to create a button for that on incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2023 04:35 AM
Full solution on servicenowguru.com
https://servicenowguru.com/system-definition/remove-activity-log-journal-entries/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2023 10:51 PM
I need to do it using scripting, and also need to create a button for that on incident form