- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2021 12:49 AM
We are using below catalog client script for mandatory attachments , but as per best practices servicenow asking us to use without gel function in 5th line (var cat_id = gel('sysparm_item_guid').value;)
kindly help me to change below code without gel method
function onSubmit() {
//Type appropriate comment here, and begin script below
var condtn = g_form.getValue('Server_com_decom');
if(condtn == 'Commission'){
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("You must attach a file to submit.");
return false;
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2021 02:01 AM
Hi
Give a final try:
function onSubmit() {
var OwnOther = g_form.getValue('Server_com_decom');
if (OwnOther == 'Commission') {
var cat_id = g_form.getValue('sysparm_item_guid');
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("You must add an attachment before submitting this request.");
return false;
}
}
}
Thanks
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2021 01:29 AM
Hi,
Try this:
var OwnOther = g_form.getValue('Server_com_decom');
if (OwnOther == 'Commission') {
var sysid = g_form.getUniqueValue();
var attach = new GlideRecord('sys_attachment');
attach.addQuery('table_sys_id',sysid);
attach.query();
if(attach.next()){
alert("You must add attachment before submitting this request.");
return false;
}
}
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2021 01:57 AM
Its not working , catalog submitting without attachment also
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2021 02:01 AM
Hi
Give a final try:
function onSubmit() {
var OwnOther = g_form.getValue('Server_com_decom');
if (OwnOther == 'Commission') {
var cat_id = g_form.getValue('sysparm_item_guid');
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("You must add an attachment before submitting this request.");
return false;
}
}
}
Thanks
Murthy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2021 01:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2021 02:20 AM
Hi Nitya
You can replace the below line
var cat_id = gel('sysparm_item_guid').value;
with
var cat_id = g_form.getValue('sysparm_item_guid');