i am getting an error getElementsByClassName(). how can i resolve it?

asha4
Kilo Contributor

i am getting an error getElementsByClassName(). how can i resolve it?

for getting the attachments length i have used this method 

1 ACCEPTED SOLUTION
10 REPLIES 10

Hi Asha,

Try this example and make necessary changes(like field name & table name) -

function onSubmit() {

 

    //Type appropriate comment here, and begin script below

 

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

 

var rowcount=0;

 

var s = g_form.getValue('si');

 

if((s == "Attach a file"))

 

{

var attachment = new GlideRecord("sys_attachment");

 

attachment.addQuery("table_name", "change_request");

 

attachment.addQuery("table_sys_id", cat_id);

 

attachment.query();

 

while (attachment.next()) {

 

rowcount++;

 

}

if(rowcount == 2)

 

{

 

return true;

 

}

 

else

 

{

 

alert("Please attach 2 attachments ");

 

return false;   }

 

}