on submit make attachment mandatory in catalog client script in service now

Priyanka153
Kilo Explorer

On submit make attachment mandatory on catalog client scrript

6 REPLIES 6

Jaspal Singh
Mega Patron
Mega Patron

Hi Priyanka,

 

If this is for Catalog item on portal you can use the Mandatory Attachment checkbox on the Catalog item form.

No code at all.

Pooja Mallikarj
Kilo Sage

Hi,

You can try below onSumit catalog client script.

function onSubmit() {
//Type appropriate comment here, and begin script below

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,

Pooja M