- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014 05:39 AM
We want a notification to be send only when the ticket is updated by someone else then the person/s on work notes list.
Is this possible to script with an advanced condition?
What I've been trying without success is the following two examples
if (current.work_notes_list != current.sys_updated_by){
answer = true;
}
OR
if (current.work_notes_list.user_name != current.sys_updated_by){
answer = true;
}
I always get it to return true even if it's updated by the person who is in the "work notes list" field.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014 08:05 AM
i hate it when at times you get a sys_id, and then when you want it, you have to dig to get it.
var gr = new GlideRecord('sys_user');
gr.query('user_name',current.sys_updated_by);
gr.query();
if (gr.next())
{
uid = gr.sys_id;
if(current.work_notes_list.toString().indexOf(uid) != -1)
answer = true;
else
answer = false;
}
else
answer = false;
If the user cannot be found in the sys_user table, it will not send - change line 13 to switch that
If it finds a matching user, it then looks and if the user Id is in the work_notes_list, it will send otherwise it will not
you can switch it by adding an ! at line 7, or swapping lines 8 and 10 around
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014 07:24 AM
I don't get this to work, now there are no notifications being send.
I've tried it by impersonating the user on work notes list and also tried it with my user, no mail was send in any of the cases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014 08:05 AM
i hate it when at times you get a sys_id, and then when you want it, you have to dig to get it.
var gr = new GlideRecord('sys_user');
gr.query('user_name',current.sys_updated_by);
gr.query();
if (gr.next())
{
uid = gr.sys_id;
if(current.work_notes_list.toString().indexOf(uid) != -1)
answer = true;
else
answer = false;
}
else
answer = false;
If the user cannot be found in the sys_user table, it will not send - change line 13 to switch that
If it finds a matching user, it then looks and if the user Id is in the work_notes_list, it will send otherwise it will not
you can switch it by adding an ! at line 7, or swapping lines 8 and 10 around
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014 08:26 AM
This one works!
I had to switch line 8 and 10 to make it work though.
Thanks a lot for the help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014 07:22 AM
how is the notification being triggered? by firing a event using a before rule or a after business rule? or using record updated on the notification template ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2014 07:24 AM
this should be your base script ....
var answer = false;
var notes = current.work_notes.getJournalEntry(-1);
var currentUser = gs.getUser().getDisplayName();
var na = notes.split("\n\n");
for (var i = 0; i < na.length; i++)
{
if(na[i].indexOf(currentUser) != '-1')
{
answer = true;
break;
}
}
if(!answer)
{
gs.addInfoMessage("Fire Event");
}