Onsubmit Client Script to check Attachments on Record producer

Chaisai
Kilo Expert

Hello,

 

I have a record producer on a custom table in custom application which has check box if checked need to attach the files , so i have been using below code it is working but even after attaching on the form i am getting same Alert and unable to submit the form , any help in this is much appreciated!

 

Onsubmit Client script code :

function onSubmit() {

attachOne = g_form.getValue('one');
attachTwo = g_form.getValue('two');
attachThree = g_form.getValue('three');

if(attachOne == 'true' || attachTwo == 'true' || attachThree == 'true') //checking if any of the attachment checkbox is ticked 
{

var att = new GlideRecord("sys_attachment");
att.addQuery("table_name", "sc_cat_item_producer"); 
att.addQuery("sys_created_by", g_user.userName); 
att.query();
if(!att.next())
{
alert("Please attach the Required Documnet to proceed with submitting.");
return false;
}

}

}

10 REPLIES 10

Even i'm facing the same issue, did you get any solution to fix this?