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

These is  a nice blog written, please refer

 

https://community.servicenow.com/community?id=community_blog&sys_id=00edd9751bb090d0ada243f6fe4bcba8 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

10 REPLIES 10

Megha Padale
Giga Guru

Hi Asha,

Check this

https://community.servicenow.com/community?id=community_question&sys_id=a9c1df6ddbdcdbc01dcaf3231f96...

If my answer helped you in any way, mark answer as helpful and correct.

Thanks and regards,

Megha.

Ruhi Jibhyenka1
Mega Guru

Hi Asha,

If you want to check 2 attachments, it means you want to validate count and not length of the attachment.

Try this code in your client script-

function onSubmit(){

var count = getSCAttachmentCount();
  if(count != 2) {
    alert(You must attach the 2 attachments');

    return false;

}

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy.

Thanks,

Ruhi.

onSubmit script error: ReferenceError: getSCAttachmentCount is not defined:
function onSubmit() {
   //Type appropriate comment here, and begin script below
   
 
           var count = getSCAttachmentCount();
  if(count != 2) {
    alert("You must attach the 2 attachments");

    return false;
 
}
}

asha4
Kilo Contributor

still i am getting reference error

 

These is  a nice blog written, please refer

 

https://community.servicenow.com/community?id=community_blog&sys_id=00edd9751bb090d0ada243f6fe4bcba8 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025