Email notification display Work Notes ONLY if they were updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2015 01:52 PM
I have a requirement in email notification to show the LATEST work notes ONLY if the work notes have been updated. Is there a way to query the updated events directly in the email notification?
The mail script I have right now will display the LATEST work notes only if there are work notes, but will show the latest work notes even when the work notes are not updated.
The notification is being triggered on the condition that either the additional comments were updated or the assignment group or assigned to changes. So I can't use a simple condition builder.
I also considered the technique in this post but I'm wondering if there is a better way to do this in 2015, this post was back in 2011.
http://www.servicenowguru.com/scripting/business-rules-scripting/checking-modified-fields-script/
<mail_script>
var worknotes = current.work_notes.getJournalEntry(1);
if (worknotes !='') {
template.print("Latest Work Notes:");
template.print(current.work_notes.getJournalEntry(1));
}
</mail_script>
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 12:29 PM
Hello Harish
What do you mean by Work Notes changes ? Is it something like work notes Updated ?
Regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 08:14 AM
Hi Leslie,
Check if the current notification is fired from a event .If yes then find the business rule from which that event is fired . in that Business rule write following kind of script .
var notesUpdated = 0 ;
if(current.work_notes.changes())
notesUpdated = 1 ;
Now in the same business rule find the instruction from which event is fired and it will be something like below
gs.eventQueue('nameOfEvent',current,parm1,parm2);
now you could replace parm1 or parm2 with notesUpdated but you need to be careful here.suppose parm2 is not used when event is fired the you could replace it like
gs.eventQueue('nameOfEvent',current,parm1,noteUpdated);
Now all you need to do with your email notification using following code
<mail_script>
if(event.parm2 == 1){
var worknotes = current.work_notes.getJournalEntry(1);
template.print(worknotes);
}
}
</mail_script>
<mail_script>
</mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 12:57 PM
I solved the issue by creating a separate notification and using the advanced condition.
If the comments changes and work notes does not change the notification is sent. I created a separate notification with the same logic, except if the work notes changes and if the comments does not change then that one is sent.
The content of the email are set accordingly so we only see the latest change when it is updated as necessary.
var worknotesChanges = current.work_notes.changes();
if (worknotesChanges) {
answer = false;
}
else {
answer = true;
}