Checklist items and worknote notifications

KB15
Giga Guru

I'd like to use checklists however they're tied to worknotes in incident. We currently have a notification for worknotes when it changes however since each checklist addition fires a worknote, this is not a useful feature.

What's the best way to prevent worknotes from being added when a checklist item is created or added? I'm not sure what condition I can use to prevent it.

1 ACCEPTED SOLUTION

KB15
Giga Guru

I've found a solution. Basically, a scripted custom condition was added to our worknotes notification:



var notes = current.work_notes.getJournalEntry(1);


if (current.work_notes.changes()){


    if ((notes.indexOf('Checklist item:')>-1) || (notes.indexOf('Checklist created')>-1) || (notes.indexOf('Checklist deleted')>-1))


          {


    answer = false;


          }


else


    {


  answer = true;


    }


}



This will suppress any triggers if the worknote includes "Checklist item" or "Checklist created" or "Checklist deleted" while still keeping the audit data.


View solution in original post

15 REPLIES 15

Hi Carl,



The object, or the notification, would be anything that would be triggered off the worknotes condition. If you have something like this in your notification condition:


find_real_file.png


...you'll have to clear this condition and switch to the advanced condition section and add the script there.


I have extra conditions-Active is true and Assigned to is Empty-could you assist me in modifying that script in such a way that I can include those?  I have tried several ways without success.

 

Thanks,

 

Heather

ty_roach
Tera Guru

Try using Checklist Pro (a ServiceNow store app).  These checklist items do NOT update worknote.  More info about Checklist Pro vs OOB Checklist:

The problem with the OOB checklists is that they are unreliable, meaning, people can change the content of the checklist item after the fact, add items, delete items, change items.  There's also no guarantee that the same checklist will appear for same situation.  There is no way to restrict who can edit the checklist or when it can be edited (like do you really want people changing checklist responses after the record has been closed).

Enter Checklist Pro.  We built Checklist Pro to solve all those problems and more.  Checklist Pro application administrators can define when checklists get created and associated with records in a table (any table - not just those that extend TASK), when these checklists can be edited, when the associated record is considered "closed" (and thus should prohibit further checklist updates).  We even added the ability to define "Required" checklist items that allow enforcement, thereby preventing a record from closing unless the required items are completed.  We've built convenience Database Views to go with the most common checklist tables, which include TASK, SYSAPPROVAL_APPROVER, CMDB_CI.

They work in the Service Portal as well as in the Classic UI.

They'll work with other Scoped Applications (like HR or SecOps or even custom scoped apps & tables).

For more information contact TyGR LLC or goto our youtube channel to see it in action.

Also - besides the classic Checkbox Item, Checklist Pro allows you to include various data types, including Textbox fields, Date, Integer, Custom Choice Lists and Reference fields.

Moritz Becker1
Tera Contributor

Hi All,

for anyone looking for a clean (enough) solution, that keeps the work notes (for audit and blame log reasons) but prevents notifications, simply add

grTask.setUseEngines(false);

to the business rule called Add worknote for checklist item CRUD (https://yourinstance.service-now.com/sys_script.do%3Fsys_id%3D734c6811c332310038e7fe0712d3ae2d)

The BR should look like this afterwards:

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("work_notes")) {
				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.work_notes = worknote;
				
				grTask.setUseEngines(false); //will prevent uneccesary notifications
				
				grTask.update();
			}
		}
}

This will prevent the notification engine from running for that update (and all other engines for that matter, but that should not matter all that much in this specific case).

Now all notifications for checklist item updates are silenced and your colleagues will be closer to disabling that pesky E-Mail filter rule that deletes everything coming from your instance.

Farewell

This should be the correct answer! Worked perfectly for me. Thanks!