Attachment file type restriction ,file not uploaded but showing in activity log

kalyani23
Tera Contributor

Hi,

In my requirement,I have a field with type attachment, and i wanted to restrict some file type and created br,so now its restircting when i upload it, and showing error msg, but still in activity log it is getting added, but that is not required, can someone provide solution for this.

find_real_file.png

thanks & regards,

kalyani

1 ACCEPTED SOLUTION

Hi,

see if you create BR on sys_attachment it will restrict but not show message

if you create BR on your table it will show error message and not restrict

In that case have both the BRs

1) it would restrict and show error message as well

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

is the record getting saved when you add that file?

Can you share BR script and configuration how you are restricting?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

this is br wch i have used,

var attach = new GlideRecord('sys_attachment');
attach.addQuery('table_name','ZZ_YYu_automation_request_task_table');
attach.addQuery('sys_id',current.u_lld_document);

attach.query();
while(attach.next()){
var strfilepdf = attach.file_name.indexOf('.pdf');
//var strfilejpeg = attach.file_name.indexOf('.jpeg');
var strfiledoc = attach.file_name.indexOf('.doc');
var strfilexlsx = attach.file_name.indexOf('.xlsx');
var strfiledocx = attach.file_name.indexOf('.docx');
var strfilezip = attach.file_name.indexOf('.zip');
var strfilezipx = attach.file_name.indexOf('.zipx');
if(attach.size_bytes > 15000000){
gs.addErrorMessage('Please upload file size within 15 mb');
current.setAbortAction(true);
blValidate_Status = false;

}
else if((strfilepdf < 0)&&(strfiledoc < 0) && (strfiledocx < 0) && (strfilezip < 0) && (strfilezipx < 0) && (strfilexlsx < 0)){
gs.addErrorMessage('Please upload file type of pdf / xlsx / doc / zip');
current.setAbortAction(true);
}
}

Hi,

BR is on which table?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

table name: u_automation_request_task_table