If you used the Checklists plugin in ServiceNow you know that it very annoyingly writes a work note every time an item is checked or unchecked. This video explains how to turn this off. In this article, I’ll explain how to write to a custom field instead of a work note, which not only avoids work note noise but also allows the end user to turn on or off checklist item activity in the Activity formatter.
1. Create a custom field called u_checklist_note on the task table
2. Disable the BR Add worknote for checklist item CRUD /sys_script.do?sys_id=734c6811c332310038e7fe0712d3ae2d
3. Do an insert and stay from the Add worknote for checklist item CRUD BR. Rename it to Add checklst note for checklst item CRUD. Replace the script with the script below:
//Updates the u_checklist_note field on the task table each time a checklist item is checked or unchecked. This is a copy of Add work note for checklist item CRUD BR but writes to a custom field instead of the work notes. This way, the work notes are not cluttered up with checklist notes.
function onBefore(current, previous) {
var grChecklist = new GlideRecord('checklist');
if (grChecklist.get(current.checklist)) {
var grTask = new GlideRecord(grChecklist.table);
if (grTask.get(grChecklist.document) && grTask.isValidField("u_checklist_note")) {
var worknote = gs.getMessage('Checklist item ');
if (current.operation() == 'insert') {
// CREATE
worknote += gs.getMessage('added: ');
} else if (current.operation() == 'delete') {
// DELETE
worknote += gs.getMessage('deleted: ');
} else if (current.operation() == 'update') {
// UPDATE
// When Checklist Item completed / uncompleted, generate a work note for the associated task record
if (current.complete != previous.complete) {
if (current.complete == true)
worknote += gs.getMessage('checked off: ');
else
worknote += gs.getMessage('unchecked: ');
} else {
worknote += gs.getMessage('updated: ');
}
}
worknote += current.name;
grTask.u_checklist_note = worknote; //writing to u_checklist_note instead of work notes
grTask.update();
//clear the field in stealth mode so that the next time the field is updated, the old value does not appear in the activity log.
grTask.u_checklist_note = '';
grTask.autoSysFields(false);
grTask.setWorkflow(false);
grTask.update();
}
}
}