Validate attachment counts

Feddy
Kilo Sage

Hi All, 

We have requirement to validate attachment on a record producer and below line is returning different value when checked in portal and in mobile.
var attlen = this.document.getElementsByClassName('get-attachment').length;

it is giving 2 if we have only one attachment. Has anyone faced similar issue?
How can i validate in client script?

Any inputs on this would be much appreciated.

Thanks,
Fedrick

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I have shared blog for this and it works in native + portal

Verify Mandatory Attachments Count on Catalog Item

If my blog helps please mark it helpful and also bookmark it

Sharing additional links as well

Possible Ways for Making an Attachment Mandatory : Service Portal/Native UI

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I have shared blog for this and it works in native + portal

Verify Mandatory Attachments Count on Catalog Item

If my blog helps please mark it helpful and also bookmark it

Sharing additional links as well

Possible Ways for Making an Attachment Mandatory : Service Portal/Native UI

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Feddy 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader