Need to show alert when attachment is not added while submitting the request in the portal.

Shaida
Kilo Contributor

Hi,

I need to show an alert when attachment is not added while submitting the request.

I am using On Submit client script.

    var cat_id = g_form.getValue('sysparm_item_guid');
    alert(cat_id);
    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;
    }

It is showing alert when attachment is added also.

@Ankur Bawiskar  Could you please help me on this.

 

Thanks in Advance...

4 REPLIES 4

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Code is not required, you can simply check this checkbox in form

find_real_file.png

Please hit like and mark my response as correct if that helps

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can check my blog and get the count of attachments; enhance it as per your requirement

Verify Mandatory Attachments Count on Catalog Item

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Shaida 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Musab Rasheed
Tera Sage
Tera Sage

Hello,

If you are fine with my response, Please hit like and mark my response as correct if that helps.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab