Script Modification
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2023 09:58 AM
Hi.
I have this code in Inbound action and now I need to change it to search for the words " in email (from integration.support.prod@segro.com" || email.from == "integration.support.test@segro.com) SMPI", "ODS" and "Kepler" and the Service assigned them to such. I tried to do it via emailBody.include... but then the incident from the entire script is not created. Any ideas?
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
//check email from
var callSI = new hmInboundEmail();
var emailFrom = callSI.checkEmailFrom(email.from);
var emailFromThirdParty = callSI.checkThirdPartyEmail(email.from);
//if email from is SEGRO/Whitelisted
if (emailFrom == 'SEGRO' || emailFrom == 'Whitelisted') {
var emailBody = email.body_text;
var maxChars = 524288;
if (emailBody.length > maxChars) {
emailBody = emailBody.substring(0, maxChars);
}
current.short_description = email.subject;
current.description = "received from: " + email.origemail + "\n\n" + emailBody;
current.contact_type = "email";
current.state = 1; //New state
if (emailFrom == 'SEGRO') {
current.caller_id = gs.getUserID();
if (email.from == "integration.support.prod@segro.com" || email.from == "integration.support.test@segro.com") {
current.assignment_group = gs.getProperty('seg.group.l3_applications'); // L3 - Applications
current.business_service = gs.getProperty("seg.business_service.SMPI");
var dateTime = new GlideDateTime();
dateTime.addSeconds(60);
gs.eventQueueScheduled('agile.solution.incident.email', current, '', '', dateTime);
} else {
current.assignment_group = gs.getProperty('hm.l1.techbar.group.sys.id'); // L1 - TechBar group
}
if (email.from == "solarwinds-noreply@segro.com") {
current.impact = 1;
current.urgency = 2;
}
}
if (email.from == "defender-noreply@microsoft.com") {
current.assignment_group = gs.getProperty('hm.l1.techbar.group.sys.id'); // L1 - TechBar group
current.impact = 1;
current.urgency = 2;
}
if (email.from == "DefenderCloudnoreply@microsoft.com") {
current.assignment_group = gs.getProperty('hm.l1.techbar.group.sys.id'); // L1 - TechBar group
current.impact = 1;
current.urgency = 2;
if (emailFromThirdParty) {
current.category = "fix required";
current.caller_id = emailFromThirdParty.getUniqueValue();
current.business_service = gs.getProperty("seg.business_service.data_warehouse");
current.assignment_group = gs.getProperty("seg.group.l3_applications");
current.u_guest_contact_email = email.from;
if (emailFromThirdParty.u_associated_service.toString() != "") { // when no service associated, then take default, not null
current.business_service = emailFromThirdParty.u_associated_service.toString();
}
}
}
if (emailFrom == 'Whitelisted') {
var whitelistedRec = callSI.whitelistedRec(email.from);
current.u_guest_contact_email = email.from;
current.company = whitelistedRec.u_company;
current.caller_id = whitelistedRec.dl_notify;
}
current.insert();
} else { //if NON - SEGRO
gs.eventQueue('hm.bouncback.email', '', email.from, email.from);
}
})(current, event, email, logger, classifier);
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2023 05:37 AM
You will have to use indexOf. Something like this:
email.from.toLowerCase().indexOf("integration.support.test@segro.com") >= 0
Please mark it Correct and Hit Like if you find this helpful!