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

Hemanth M1
Giga Sage
Giga Sage

Hi Asha,

 

shall we know whats the error and your logic.

 

/Hemanth

Accept and hit Helpful if it helps.

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

asha4
Kilo Contributor

function onSubmit() {
//Type appropriate comment here, and begin script below


if (this.document.getElementsByClassName('get-attachment').length != 2) {
alert('You must attach the 2 attachments');
return false;


}

}

asha4
Kilo Contributor

i am using this code in  record producer  for submitting the attachment both in portal and instance with length must be 2.

Ruhi Jibhyenka1
Mega Guru

Hi Asha,

You can do it in a before business rule and check for file length.

Below is the script-

var str = current.file_name;

str = str.split('.');

var strtlen = str[0].length;

if(strlen >100) {

current.file_name = str[0].slice(0,99);

}

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

Thanks,

Ruhi.