- 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
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
01-04-2024 04:46 AM
It works for me.