- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
I've been pretty busy lately with my switch over to Crossfuze Solutions and my blogging time has suffered a lot so I thought it was time to post a couple articles.
A client of ours has an integration using an Inbound Email Action that reads emails from a specific user and creates new records based on the contents of the message, one record for each line in the email. It's meant to create a few records every couple of days and was working quite nicely until one day an email was mistakenly sent with over 2,000 lines in the message. Obviously it was an error on the transmission side, but the Inbound Email Action just chugged away and created all 2,000+ records.
So in order to avoid the problem in the future, I added a simple check in the script to check how many records were sent to us. I won't put the whole script here, but you'll get a good idea:
(function(){
// Parse email message
var recordArray = email.body_text.split('\n');
var numberOfRecords = recordArray.length;
//assume a problem email if there are more than 20 records included
if (numberOfRecords < 21) { // << *********** this is the important part
for (i = 0; i < numberOfRecords; i++) {
//the code to create the actual records goes here
...
...
...
}
} else {
gs.eventQueue("sys_email.u.mail_integration.max.records.exceeded", sys_email, null, null);
}
event.state="stop_processing";
})();
There is an email notification setup to fire on the event and send out an email to the ServiceNow administators group to investigate the email. So now we are safe if we ever receive an email with more than 20 entries in it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.