if incident record if their any attachment no need to show any alert .If attachment is not their show the alert

venkyp
Kilo Explorer

hi ,

9 REPLIES 9

Hi Shloke: I agree.



Hi Venkat,



Shloke's response would be ideal to achieve your requirements. Please let us know you get any issue.


sarfraz3
Mega Expert

you can do this by onsubmit client script. On submit check the attachement ad return true or false accordingly. Will post the check attachmnet code shortly.



Thanks



Note: please hit helpful/correct based on impact


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



  var gr = new GlideRecord("sys_attachment");


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


  gr.addQuery("table_sys_id", inc);


  gr.query();




  if (!gr.next()) {


  alert("You must attach a file to submit.");


  return false;


 


  }


reginabautista
Kilo Sage

Hi you may achieve this by querying the sys_attachment table using client script. Try the below code:



var sysid = g_form.getUniqueValue();


  var attach = new GlideRecord('sys_attachment');


  attach.addQuery('table_sys_id',sysid); //sysid= replace with your current record's sysid


  attach.query();


  if(attach.next()){


  alert("form contains attachment");


  }



more info here:



Re: How do I check file attachment in a form by clientscript


shloke04
Kilo Patron

Hi,



Did you got a chance to Test the Solution provided for your query.



If your query is Resolved, Please mark the answer as correct so that the thread can be removed from the Unanswered list.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke