particular domain mail id needs to create an incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 01:54 AM
HI Community,
I have a requirement, only particular domains mail id need to create an incident. we have an inbound email action created in an incident table.
Inbound email action condition : new global.KAL_Inbound_Actions().validSender(email.recipients.toLowerCase())||email.recipients.indexOf(gs.getProperty('instance_name')+'@service-now.com') > -1
Script include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 02:08 AM
try this
1) update property as this -> gmail.com,yahoo.com
2) update script include as this
var KAL_Inbound_Actions = Class.create();
KAL_Inbound_Actions.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validSender: function(recipients) {
var validEmail = false;
var allowedDomains = gs.getProperty("itsm.email").toLowerCase().split(',');
// Extract sender email from recipients (assuming recipients is a string of emails)
var recipientList = recipients.split(',');
for (var i = 0; i < recipientList.length; i++) {
var email = recipientList[i].trim();
for (var j = 0; j < allowedDomains.length; j++) {
var domain = allowedDomains[j].trim();
// Check if email ends with @domain
if (email.endsWith("@" + domain)) {
validEmail = true;
break;
}
}
if (validEmail) break;
}
return validEmail;
},
type: 'KAL_Inbound_Actions'
});
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 04:44 AM
HI @Ankur Bawiskar ,
Thanks for the response
I tried this but it did not work.
Created a new system property (with values as mentioned) and update that property in script include like your.
And i tried sending an mail from my mail id (i have that domain name in my mail id) but it did not work...incident not created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 04:57 AM
did you debug and see what came in logs?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 05:09 AM
HI @Ankur Bawiskar ,
Yes,
Actual inbound condition : new global.KAL_Inbound_Actions().validSender(email.recipients.toLowerCase())||email.recipients.indexOf(gs.getProperty('instance_name')+'@service-now.com') > -1
so i removed ||email.recipients.indexOf(gs.getProperty('instance_name')+'@service-now.com') > -1 and tested why because with this part incident is getting created even with the old script when i sent mail from my mail id to dev instances mail id. incident is getting created so i removed it and tested.
this is the log i recieved
(Skipping script 'KAL_Create Incident - New', condition 'new global.KAL_Inbound_Actions().validSender(email.recipients.toLowerCase())' failed)