- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2022 02:00 AM
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.
thanks & regards,
kalyani
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2022 02:59 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2022 02:36 AM
Hi,
your BR should be on sys_attachment to abort insertion
before Insert
Condition: current.table_name == 'ZZ_YYu_automation_request_task_table'
Script:
var strfilepdf = current.file_name.indexOf('.pdf');
var strfiledoc = current.file_name.indexOf('.doc');
var strfilexlsx = current.file_name.indexOf('.xlsx');
var strfiledocx = current.file_name.indexOf('.docx');
var strfilezip = current.file_name.indexOf('.zip');
var strfilezipx = current.file_name.indexOf('.zipx');
if(current.size_bytes > 15000000){
gs.addErrorMessage('Please upload file size within 15 mb');
current.setAbortAction(true);
}
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);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2022 02:49 AM
In that case error msg may not appear for user when any doc if they upload which is not supported. is any other way in which we can do, instead of creating br in sys_attachment table.please suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2022 02:59 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2022 03:00 AM
Thank u
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2022 03:16 AM
Glad to help.
Please mark responses helpful as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader