ServiceNow Prevent email signatures from attaching to tickets... but display the blocked attachment from the incident in case they are needed
the default property can be used
glide.email.inbound.image_sys_attachment.filter.minimum_bytes
however this solution is a more granular check that will also allow blocked attachments to be recovered to the incident
inbound email code:
var enableFlag = gs.getProperty('email.attach.flag');
if (enableFlag && newRec.getTableName() == 'incident') {
alterAttachment(emailRec.sys_id.toString(), newRec.sys_id.toString(), newRec.getTableName()); //, newRec); Test Pending
}
//Copy attachments from email to created record
GlideSysAttachment.copy('sys_email', emailRec.sys_id.toString(), newRec.getTableName(), newRec.sys_id.toString());
function alterAttachment(emailRecsID, newRec_sysID, newRec_TableName) { //, newRec) { Rest Pending
//Code added as part of ITSM-11382 to prevent small images and specific
//image type to be skipped for a image
var result = false;
var sizeIs = gs.getProperty('moj.email.attach_size');
var typeIs = gs.getProperty('moj.email.attach_type');
var grc = new GlideRecord("sys_attachment");
grc.addQuery('table_sys_id', emailRecsID);
var aCond = grc.addQuery('size_bytes', '<', sizeIs);
aCond.addOrCondition('content_type', 'NOT IN', typeIs);
grc.query();
while (grc.next()) {
result = true;
var attRec = new GlideRecord('u_moj_temp_email_attachments');
attRec.initialize();
attRec.u_table_class = newRec_TableName; //'incident';
attRec.u_content_type = grc.content_type;
attRec.u_email_reference = emailRecsID;
attRec.u_file_name = grc.file_name;
attRec.u_reference_id = newRec_sysID;
attRec.u_size = grc.size_bytes;
attRec.u_table_sys_id = newRec_sysID;
attRec.u_target_table = 'incident';
sID = attRec.insert();
grc.table_sys_id = sID;
grc.update();
}
return result;
}
attachments below the size threshold are not attached to the incident, but visible from a tab (custom table extended from DL_matcher