- 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:52 PM
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; }
}