File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Business Rules/Enforce File Upload Restrictions for HR Document Submission Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ var hrTask = new GlideRecord ( 'sn_hr_core_task' ) ;
2+
3+ if ( hrTask . get ( current . table_sys_id ) &&
4+ hrTask . hr_Task_type == 'upload_documents' &&
5+ hrTask . short_description == 'submit photo identification' ) {
6+
7+ var fileName = current . file_name . toString ( ) ;
8+ var fileSize = current . size_bytes . toString ( ) ;
9+ var fileType = fileName . split ( '.' ) . pop ( ) . toLowerCase ( ) ;
10+
11+ // Check file size (must not exceed 2MB)
12+ if ( parseInt ( fileSize ) > 2000000 ) { // 2MB in bytes
13+ gs . addErrorMessage ( 'Maximum file size is 2 MB' ) ;
14+ current . setAbortAction ( true ) ; // Abort if file size exceeds 2 MB
15+ return ;
16+ }
17+
18+ // Check file type (must be JPG or JPEG)
19+ if ( fileType !== 'jpg' && fileType !== 'jpeg' ) {
20+ gs . addErrorMessage ( 'File must be in JPG or JPEG format' ) ;
21+ current . setAbortAction ( true ) ; // Abort if not JPG or JPEG
22+ return ;
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ This code ensures that when a user uploads a document related to a specific HR task, the uploaded file meets
2+ certain criteria: it must be in JPG or JPEG format and must not exceed 2 MB in size. If either condition is violated,
3+ the upload is halted, and an appropriate error message is displayed to the user, maintaining the integrity of the data
4+ being processed.
You can’t perform that action at this time.
0 commit comments