Skip to main content

Hello All, 

In the assystETM we have a mailbox reader where we take key words from the subject line and then match it to a relevant Import Profile so we can be a bit more granular in how we log emails from application system alerts.

Now we want to expand it so we can read specific text within the body of an email and then apply that as a match to an Import Profile, please see below my JS:

 

if (variables.subject.contains("Change based alerts")) {"ABG-D365-INCIDENT"}
else if (variables.subject.contains("Workflow Approval")) {"ABG-D365-INCIDENT"}
else if (variables.subject.contains("BYOD FI02")) {"ABG-D365-INCIDENT"}
else if (variables.subject.contains("Post Journal")) {"ABG-D365-INCIDENT"}
else if (variables.subject.contains("An error occurred while processing batch job PN")) {"ABG-AX2012-INCIDENT"}
else if (variables.subject.contains("AIF Detail Report - Premier Nutrition")) {"ABG-AX2012-INCIDENT"}
else if (variables.subject.contains("An error occurred while processing batch job ASN")) {"ABG-AX2012-INCIDENT"}
else if (variables.subject.contains("AIF Inbound - LIVE")) {"ABG-AX2012-INCIDENT"}
else if (variables.subject.contains("AIF Outbound - LIVE")) {"ABG-AX2012-INCIDENT"}
else if (variables.subject.contains("ASN & PN")) {"ABG-AX2012-INCIDENT"}
else if (variables.subject.contains("SQL Server Message")) {"ABG-AX2012-INCIDENT"}
else if (variables.subject.contains("Trading")) {"ABG-AXT-INCIDENT"}
else if (variables.subject.contains("Manufacturing")) {"ABG-AXM-INCIDENT"}
else if (variables.richEmailBody.contains("Source: AX4KWTLIVE")) {"ABG-AXT-INCIDENT"} 
else if (variables.richEmailBody.contains("Source: AX4ABN")) {"ABG-AXM-INCIDENT"} 
else if (variables.richEmailBody.contains("Source: AX5VIS_LIVE")) {"ABG-AX2009-INCIDENT"} 
else if (variables.richEmailBody.contains("Source: ABG_DYNAX6_CORE_LIVE")) {"ABG-AX2012-INCIDENT"}
else {"ABG-D365-INCIDENT"}

The tickets which are looking for text within the subject are still being logged successfully, however all of the test emails where I am looking at variables.richEmailBody.contains are still being logged, just not with the import profile I would want and they are defaulting to the else statement ABG-D365-INCIDENT.

I have tried lots of different things and I am not an expert in JavaScript so I was wondering whether anybody had done something similar and can help me out here…..please.

Have you made sure there are no HTML tags in the target string when you debug the import in the mapper. I’ve had emails before where the ‘Source’ is either formatted between <b></b> or <span></span> tags. Alternatively, in a table? 


Have you made sure there are no HTML tags in the target string when you debug the import in the mapper. I’ve had emails before where the ‘Source’ is either formatted between <b></b> or <span></span> tags. Alternatively, in a table? 

Thanks Steve, I have it now working as I want.


Reply