logo

NJP

How do I make the attachment field mandatory in Service Portal or Employee Center?

New article articles in ServiceNow Community · Feb 15, 2026 · article

 

Hello, I just wanted to contribute by sharing how to make an attachment mandatory in ServiceNow when, for some reason, you can’t use the default “Mandatory attachment” button on the catalog item. I found a very simple way to do it and wanted to share it since there isn’t a place in the Community that gets straight to the point.

1. Create a Catalog Client Script

2. Required things to fill in:

  • Type: OnSubmit
    (We do it in OnSubmit because this will prevent the user from submitting the form until they attach something.)

Only select Applies on a Catalog Item view. If you select Applies on Requested Item and Catalog Task , it will cause an error, especially if the user removes the attachment.

In the script, copy this:

 

 

function onSubmit() { if (this.document.getElementsByClassName('get-attachment').length == 0) { g_form.addErrorMessage('please attach something'); return false; } }

 

g_form.addErrorMessage('please attach something');

 

This part of the code will show a default ServiceNow alert, informing the user that they cannot submit anything until an attachment is added:

And that’s it — it’s that simple.

Greetings from Colombia

 

View original source

https://www.servicenow.com/community/developer-forum/how-do-i-make-the-attachment-field-mandatory-in-service-portal/m-p/3489491#M1247382