- 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 11:24 PM
Hi Asha,
Check this
If my answer helped you in any way, mark answer as helpful and correct.
Thanks and regards,
Megha.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2020 11:24 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2020 11:32 PM
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;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2020 11:32 PM
still i am getting reference error

- 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