- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2015 10:45 AM
Hi everyone,
I've seen a lot of script for checking attachments, but I can't seem to track one down that is conditional on whether or not a catalog variable is blank. I have this portion already:
function onSubmit()
{
var cat_id = gel('sysparm_item_guid').value;
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "sc_cart_item");
gr.addQuery("table_sys_id", cat_id);
gr.query();
if (!gr.next()) {
alert("Attach manager and/or site manager's approval email for cart movement");
return false;
}
}
I know that I need to add something to this that checks one variable and if it returns "null" to make it mandatory for attachments. Any help would be appreciated.
Thank you,
Amandah
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2015 11:13 AM
Amandah,
If i'm understanding your question, you'll probably just need to add an additional if condition at the top of the script, something like...(i haven't tested this, fair warning)
function onSubmit()
{
if (g_form.getValue('FIELD_NAME') == '') { //replace with whatever your catalog variable name is
var cat_id = gel('sysparm_item_guid').value;
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "sc_cart_item");
gr.addQuery("table_sys_id", cat_id);
gr.query();
if (!gr.next()) {
alert("Attach manager and/or site manager's approval email for cart movement");
return false;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2015 02:06 PM
Hi Christopher,
I was able to try it out and it worked exactly as expected. Thank you for your assistance!
Amandah