- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 12:33 AM - edited 01-23-2023 12:16 AM
I need this inbound email action to be run only for ITIL users.
what changes do i need to do in this script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 02:57 AM
Hi @servicenow lath ,
try below code.
var mail=email.origemail;
var usr=new GlideRecord('sys_user');
usr.addQuery('email',mail);
usr.query();
if(usr.next()){
var sysid=usr.sys_id;
var usrRole=new GlideRecord('sys_user_has_role');
usrRole.addQuery('user',sysid);
usrRole.addQuery('role','give ITIL role sysid');
usrRole.query();
if(!usrRole.next()){
//add your inboud action script it will work for role other than ITIL
}
}
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 01:49 AM
Hi @devservicenow k ,
Emails are disabled both sending and receiving on PDIs.
https://developer.servicenow.com/blog.do?p=/post/sending-emails-from-pdis/
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 01:39 AM
i need this Inbound should not run for ITIL users how to write for that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 01:02 AM
In line no 2 you can write an if condition stating and end the bracket in line no 47
if (gs.hasRole("itil")) {
//write your code here
}
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 01:37 AM
@Basheer i need this inbound actions should not be run for ITIL users. how to write for that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 01:54 AM
if (!gs.hasRole("itil")) {
//write your code here
}
You just need a ! before gs.hasRole(itil)
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.