- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2020 10:42 PM
i am getting an error getElementsByClassName(). how can i resolve it?
for getting the attachments length i have used this method
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2020 11:37 PM
These is a nice blog written, please refer
https://community.servicenow.com/community?id=community_blog&sys_id=00edd9751bb090d0ada243f6fe4bcba8
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2020 10:55 PM
Hi Asha,
shall we know whats the error and your logic.
/Hemanth
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2020 10:59 PM
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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2020 11:01 PM
i am using this code in record producer for submitting the attachment both in portal and instance with length must be 2.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2020 10:57 PM
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.