File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Client-Side Components/Catalog Client Script/Document validation Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ var DocumentValidationHelper = Class . create ( ) ;
2+ DocumentValidationHelper . prototype = Object . extendsObject ( AbstractAjaxProcessor , {
3+ validateAttachments : function ( ) {
4+ var itemId = this . getParameter ( 'sysparm_item_id' ) ;
5+ var attachmentGR = new GlideRecord ( 'sys_attachment' ) ;
6+ attachmentGR . addQuery ( 'table_name' , 'sc_req_item' ) ;
7+ attachmentGR . addQuery ( 'table_sys_id' , itemId ) ;
8+ attachmentGR . query ( ) ;
9+
10+ while ( attachmentGR . next ( ) ) {
11+ var fileName = attachmentGR . file_name . toLowerCase ( ) ;
12+ if ( ! fileName . endsWith ( '.pdf' ) && ! fileName . endsWith ( '.docx' ) ) {
13+ return 'Only PDF or DOCX files are allowed.' ;
14+ }
15+ if ( attachmentGR . size_bytes > 5 * 1024 * 1024 ) {
16+ return 'File size exceeds 5MB limit.' ;
17+ }
18+ }
19+
20+ return 'valid' ;
21+ }
22+ } ) ;
You can’t perform that action at this time.
0 commit comments