Catalog client script

roomawakar
Tera Contributor

Hi,

I am creating a new catalog item where I need to check if there is an attachment before submitting the request, but that onSubmit client script is throwing an error.

 

Can someone please help what is the issue and how can I rectify it?

function onSubmit() {

   //Type appropriate comment here, and begin script below

   

    var cat_id_return = gel('sysparm_item_guid').value;

    alert('Happy '+cat_id_return);

    var gr = new GlideRecord("sys_attachment");

    gr.addQuery("table_name", "sc_cart_item");

    gr.addQuery("table_sys_id", cat_id_return);

    gr.query();

    if (!gr.next()) {

        alert("Please attach the Mandatory attachment for Bulk Upload.");

        return false;

    }

   }

2 REPLIES 2

Elijah Aromola
Mega Sage

Are you able to use the OOB mandatory attachment option? 

 

ElijahAromola_0-1732201984458.png

 

Mohammed Al-Mar
Tera Guru

You can make the attachment mandatory by configuring it in the catalog item record.

MohammedAlMar_0-1732786067538.png