How to check if an attachment on a record producer is empty or not on Service Portal

AmenaA
Giga Guru

Looked here on community, using the following in the on-submit client script should work is what it says:

 

if (this.document.getElementsByClassName('get-attachment').length == 0 ) {
    alert('kindly attach document.');
    return false;
}
 
But it seems to display alert regardless of it be 0 or 1 or more attachments.
 
Edit: The above code seems to work fine for a catalog item, but not for a record producer
 
Thanks In Advance
 
1 ACCEPTED SOLUTION

AmenaA
Giga Guru

Hide the OOB attachment (This option is present under the "Portal Settings" Tab)

Create an "Attachment" variable & use client script / UI policy to validate if attachment is filled in or not

View solution in original post

2 REPLIES 2

HarshwardhanJ
Tera Contributor

You can try this solution:

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0723548

 

Mark correct and helpful if it solves your issue

 

Regards,

HarshwardhanJ

AmenaA
Giga Guru

Hide the OOB attachment (This option is present under the "Portal Settings" Tab)

Create an "Attachment" variable & use client script / UI policy to validate if attachment is filled in or not