GlideRecord query not working??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2018 08:38 AM
hi all,
I've got an onSubmit catalog client script that is meant to prevent the submission of a catalog item if there is no attachment already attached to the form. I'm using a script I've used before, in the other cases it works fine. However in this catalog client script, the script is breaking on the line identified below. The upper part of the script is checking if a certain field is empty, and if it is empty it then checks if there's an attachment...and if there is no attachment it should then throw the "alert()". Anyone see why my var attachment = new GlideRecord('sys_attachment'); line is breaking the script?
thanks!
Here's the full script:
function onSubmit() {
//check first if Entry #1 fields are entered
g_form.addInfoMessage('item_number1 is '+g_form.getValue('item_number1'));
if (g_form.getValue('item_number1') != ''){
return;
}
else {
//check for attachment
g_form.addInfoMessage('item_number1 is empty');
var sys_id = gel('sysparm_item_guid').value;
g_form.addInfoMessage('hello'); //this message is being displayed
var attachment = new GlideRecord('sys_attachment'); //this line appears to breaking the script
g_form.addInfoMessage('hello2');// this message is NOT being displayed
attachment.addQuery('table_name','x_cur_erp_sm_request');
attachment.addQuery('table_sys_id',sys_id);
attachment.query();
if (!attachment.next()) {
alert ("Please attach a completed Service Delivery Request form before submitting this request if not using the available fields on the form.");
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2018 10:13 AM
Thanks Michael, I'll check it out!