How to handle multiple uploads inside a single Catalog Item variable in Service Portal?

NikhithaNikki
Tera Contributor
Hi Community,
I am working on a Service Portal Catalog Item requiring conditional attachment validation on submission. Based on form answers, a user might need to attach multiple files (e.g., up to 2 or more files).
I am encountering a platform limitation and a script execution error that I need your guidance to solve.
 
1. The Variable Limitation Issue
I am using a Catalog Variable of type Attachment. However, when testing in the Service Portal, this variable type acts as a single-file slot. Whenever a user uploads a new file, it replaces/overwrites the previous attachment instead of adding it to a list. [1, 2, 3, 4]

NikhithaNikki_0-1781600826267.png

 

Is there an out-of-the-box configuration to allow a single attachment variable to accept multiple files
5 REPLIES 5

Rafael Batistot
Kilo Patron

@NikhithaNikki 

 

The Attachment catalog variable is technically bound to one sys_attachment record per variable.
In Service Portal, the widget behind this variable enforces single-file behavior, so each new upload replaces the previous file by design.

 

This is not a bug, it is a platform limitation.

 

If this response was helpful, please mark it as Helpful and, if applicable, as Correct, this helps other users find accurate and useful information more easily.

Yogesh11bhatt
Kilo Guru

Hi @NikhithaNikki ,

What you're experiencing is the expected out-of-the-box behavior of the platform.

The Attachment variable type is designed to hold only a single file. When a user uploads another file to the same Attachment variable, the new file replaces the existing one. There is no out-of-the-box configuration that allows a single Attachment variable to store multiple files.

If you need users to upload multiple files conditionally, consider one of the following approaches:

Option 1: Multiple Attachment Variables

If there is a known maximum number of files (for example, up to 3), create multiple Attachment variables (Attachment 1, Attachment 2, Attachment 3) and use Catalog UI Policies to show or make them mandatory based on the user's selections.

Option 2: Use Native Attachments

If the number of files is dynamic or unknown, use the platform's native attachment functionality (paperclip) instead of an Attachment variable. You can then validate the attachment count during submission using an onSubmit Catalog Client Script combined with a GlideAjax call to a Script Include that checks the corresponding sys_attachment records.

This approach provides greater flexibility when users may need to upload multiple supporting documents.

Hope this helps clarify the platform limitation!

Please mark this answer as Helpful if it resolves your question. 🙂

 

Thanks,
Yogesh Bhatt

PoonkodiS
Giga Sage

Hi @NikhithaNikki 

The ServiceNow Attachment variable is designed by design to only accept a single file. Because this variable type extends the string data type, updating it with a second file replaces the older attachment instead of appending it. 
To attach multiple files to a catalog item, use the default out-of-box (OOB) paperclip attachment icon on the Service Portal. 
Ref :

1.If you want to attach multiple attachments then you have to create an attachment macro variable.

Solved: how to upload multiple files with the attachment v... - ServiceNow Community

2.follow method B,The original script in the article uses the Not Equal To (!=) operator. This creates a very strict condition that only allows submission if the user attaches the exact number specified—nothing more, nothing less.changing it to Less Than (<) 

Making Attachment Mandatory for a catalog item dep... - ServiceNow Community

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

 

 

 

 

Tanushree Maiti
Tera Patron

Hi @NikhithaNikki 

 

Recent days, we got the same kind of requirement and faced this issue.

Attachment variable will allow single attachment and replace by latest one. It is OOB behaviour.

 

Convey business if additional attachment needs to upload, click on paper clip icon on grey header of catalog form. 

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti