- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2016 11:49 AM
Hi,
I am using the inbound email notification Update Case via AcceptReject, Where I need to modify the condition on this. Given the requirement below.
Current Logic: ((new CSEMailUtil).isUserExist(email.from)) && (current.contact.email == email.from)
New Logic: ((new CSEMailUtil).isUserExist(email.from)) && ((current.contact.email == email.from) OR (user is on the customer update list))
It has to accept the email from who are there in watch list. So please assist me.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2016 10:06 AM
Blow code works for me.
Script Include:-
==================
var isEmailInList = Class.create();
isEmailInList.prototype = {
initialize: function() {
},
isEmailInWL : function(list, email) {
var u = new GlideRecord('sys_user');
u.addQuery('email', email);
u.query();
if(u.next())
{
var id = u.getValue('sys_id');
var lst = list.toString();
var array = lst.split(",");
for(var i = 0; i < array.length; i++)
if(array[i] == id)
{
return true;
}
else{
return false;
}
}
},
type: 'isEmailInList'
};
Condition:-
(((new CSEMailUtil).isUserExist(email.from)) && (current.contact.email == email.from)) || ((new isEmailInList).isEmailInWL(current.watch_list, email.from))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2016 12:05 PM
narender,
Create a new script include and name it as getEmails and add this script in there
function getEmails(id){
var arr=[];
var gr= new GlideRecord('sys_user');
gr.addQuery('sys_id','IN',id);
gr.query();
while(gr.next()){
arr.push(gr.getValue('email'));
}
return arr.toString();
}
Your modified condition will be
((new CSEMailUtil).isUserExist(email.from)) && ((current.contact.email == email.from) || (getEmails(current.<put your watch_list field name here>.toString()).indexOf(email.from.toString())>-1))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2016 12:06 PM
That was my approach first, but then realized you don't need to get ALL the users in the watch list, you only need to get one (the one you are checking) and see if their sys_id is in the list.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2016 12:13 PM
LOL, I agree. I was in a hurry to provide an answer.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2016 12:05 PM
Here's how I would do it. Create a script include called isEmailInList. Take out the sample code and replace it with this function.
function isEmailInList(list, email) {
var u = new GlideRecord('sys_user');
if (u.get('email', email)) {
if (list.indexOf(u.getValue('sys_id')) > 0)
return true;
}
return false;
}
Now in your condition, add
|| isEmailInList(current.watch_list, email.from)
Modify current.watch_list to what ever list field you want to use.
Note: completely untested.