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
the table can also be cleared when the incident is closed, for that particular incident
if you click the 'move to incident' it will add it to the incident and remove it from the temp table
UI Action:
function onClickCheck() {
if (g_list.getChecked().length < 1) {
alert("You have not selected any Actions to unlink from this View configuration.");
return false;
} else {
//
}
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined') {
var ga = new Email_Attachment_Control().updateAttachment(current);
// var url = '/incident.do?sys_id=39d086db1b8b7c906248a822b24bcbf4';
// action.setRedirectURL(url);
}
script include:
var Email_Attachment_Control = Class.create();
Email_Attachment_Control.prototype = {
initialize: function() {},
updateAttachment: function(grObj) {
//Update the Attachment record with details
var sysID = grObj.sys_id;
var refID = grObj.u_reference_id;
var flag = false;
var attRec = new GlideRecord('sys_attachment');
attRec.addQuery('table_sys_id', sysID);
attRec.query();
if (attRec.next()) {
attRec.table_name = 'incident';
attRec.table_sys_id = refID;
attRec.update();
GlideSysAttachment.copy('sys_email', current.u_table_sys_id.toString(), 'incident', current.u_reference_id.toString());
this.removeAttachmentRef(sysID);
}
},
removeAttachmentRef: function(s_id) {
//Remove the record reference from the Temp table
var remRecord = new GlideRecord('u_moj_temp_email_attachments');
remRecord.addQuery('sys_id', s_id);
remRecord.query();
if (remRecord.next()) {
remRecord.deleteRecord();
}
},
type: 'Email_Attachment_Control'
};
(ServiceNow )
(
Comments
Post a Comment