How to Check attachment attached or not on submit client script

dheeru_1994
Tera Contributor

Hii All 
 i need to check attachment has attach or not by using on submit client script  
like i  make one catalog item in that i want to check that this catalog item has attachment or not  
i try many thing but no luck
your help highly appreciated 
thanks and regards 
Dheerendra 

10 REPLIES 10

Community Alums
Not applicable

Hi @dheeru_1994 

 

I tried your problem on my instance and I got the solution, you can check the below got it's working for me 

SarthakKashya2_0-1712645102458.png

function onSubmit() {
    //Type appropriate comment here, and begin script below
    var sysid = g_form.getUniqueValue();
	alert("Check id = " + sysid);
    var attachGR = new GlideRecord('sys_attachment');
    attachGR.addQuery('table_sys_id', sysid);
    attachGR.query();
    if (attachGR.next()) {
        alert("form contains attachment");
    }else{
		alert("No attachment ");
		return false;
	}
}

 

Please mark correct and helpful if it's works for you

Thanks and Regards 

Sarthak

dheeru_1994
Tera Contributor

Sir 
apki script chal rahi hai par client side pe glide record hum use nahi karte hai  or bhi hum isko kis tareeke se get kar sakte hai 

Community Alums
Not applicable

@dheeru_1994 

Thanks for replay, 

This glideRecord is only for checking if the entry got in sys_attachment table or not for the attachment. If not than we simply return false, so the form would not be saved.

 

Can you please tell me what you want to get ? 

 

Thanks and Regards 

Sarthak

if any other way to get this same requirement with on submit client script 

what if some one reject that i do not want to use glide record