excluding certain attachments from being included in an incident

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 02:36 PM
Hello All,
I'd like to see if someone can help. I have this script in an inbound email action. so when someone emails a company email address, an incident gets created. I'd like see if I can add code so that only files with the extension .pdf that are attached to the email, can be attached to the incident. everything else would be blocked.
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
var foo = new EmailUtils();
var sid = foo.getUserFromEmailAddress(email.from);
var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id', sid);
userGR.query();
userGR.next();
var companyGR = new GlideRecord('core_company');
companyGR.addQuery('name', userGR.company.name);
companyGR.query();
companyGR.next();
current.caller_id = userGR.sys_id;
current.opened_by = userGR.sys_id;
current.u_contact = userGR.sys_id;
current.description = email.body_text;
current.company = companyGR.sys_id;
current.location = userGR.location.sys_id;
current.incident_state = 1;
current.notify = 2;
current.contact_type = "email";
current.assignment_group.setDisplayValue(gs.getProperty('mycompany.assignment_group.default_group'));
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
if(email.importance != undefined)
if (email.importance == "High")
current.priority = 1;
if (email.body.priority != undefined)
current.priority = email.body.priority;
current.insert();
event.state="stop_processing";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 05:09 PM
Thats a really good and interesting question.
Some things to consider- I assume you do accept other attachment types in the system and ONLY for this use case you want to specifically only accept PDF.
If you only accepted PDFs or wanted to exclude certain types- you can check out the system properties to whitelist or blacklist.
Another thing i suppose you can do if there is a way to uniquely identify these is.. A BR on Insert to attachment table that checks the file type for attachments for records attached to the email generated incidents on this table and aborts the Insert.
I do suspect there is another way to handle it that will be posted about.- The easiest would be an addition to your script but i think inbound attachments are handled elsewhere.