- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 05:11 AM
Hie All,
Please help me out with below query
have to write a validation for attachment for Change Request form, my requirement is if category is " Software" and Risk is " Very High" then when user tries to save the form, he should get an error as " attachment mandatory."
My code is below:
In below how I can validate if attachment is type .jpeg then only allow.
I have written a Before BR on change request table, on Insert and Update the conditions as If
1 category is " Software" and Risk is " Very High"
2 Category is " Software" and Risk changes to " Very High"
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 05:40 AM
Hi @Ankita NA ,
Try below code -
if(current.category == "Software" && current.risk == '1'){
var attachment = new GlideRecord("sys_attachment");
attachment.addQuery("table_sys_id", current.sys_id);
attachment.addQuery('content_type','image/jpeg');
attachment.query();
if(!attachment.next()){
gs.addErrorMessage("Attachment is mandatory");
current.setAbortAction(true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 05:40 AM
Hi @Ankita NA ,
Try below code -
if(current.category == "Software" && current.risk == '1'){
var attachment = new GlideRecord("sys_attachment");
attachment.addQuery("table_sys_id", current.sys_id);
attachment.addQuery('content_type','image/jpeg');
attachment.query();
if(!attachment.next()){
gs.addErrorMessage("Attachment is mandatory");
current.setAbortAction(true);
}
}