- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2016 09:23 AM
Hi guys, i was wondering if someone can gave me some advice of how to make mandatory the attachments before the submit in the change request form. Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2016 09:34 AM
Try an onSubmit client script. Something like this:
function onSubmit(){
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_name','change_request');
attachment.addQuery('table_sys_id',current.sys_id);
attachment.query();
if(!attachment.next()){
alert ("Please include attachment");
return false;
}
}
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2016 09:34 AM
Try an onSubmit client script. Something like this:
function onSubmit(){
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_name','change_request');
attachment.addQuery('table_sys_id',current.sys_id);
attachment.query();
if(!attachment.next()){
alert ("Please include attachment");
return false;
}
}
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2016 11:46 AM
was very useful Tim!!!
just one thing... current is running on the server side, i just need to change that to work in the client side.
this one works for me...
function onSubmit(){
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_name','change_request');
attachment.addQuery('table_sys_id', g_form.getUniqueValue());
attachment.query();
if(!attachment.next()){
alert ("Please include attachment");
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2016 11:53 AM
Glad it helped! Yes, your method for sure makes more sense.
It's not considered best practice to use GlideRecord in a client script, so a GlideAjax call would be best when using client script. The other option, which may be even better, as it's less code, and all server side, is the before business rule mentioned in the other two replies on this post.
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2022 09:01 PM
GlideRecord is working in client script?