- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Team,
I have got a requirement where we need to restrict only 3 attachments for one variable and the 3 attachments variable size have to be less than 5MB. This requirement is mainly to build a catalog form.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Do you mean you want to restrict attachments on a catalog item to a maximum of three and a total restriction of max 5MB? I don't think you can robustly achieve this without customizing the catalog widget or creating a custom variable widget. You could use an attachment type variable x3 and the max_file_size attribute to restrict the size individually. If you can't reason with business about the requirements then it is achievable with widget development if you are comfortable with angularjs
One options is to do something server-side with the attachments - they are immediately added to sys_attachment when you upload them but they refer to the sc_cart_item table and a sys_id that is generated inside the sc catalog item widget and can be found in the data object.
Or client side in angularjs you can access information about the attachments in the scope of the sc catalog item widget. For example on the catalog page in the portal add an attachment from the bottom and paste this into the browser devtools console.
angular.element("#sc_cat_item").scope().$parent.attachments
//prints
[
{
"ext": "csv",
"size_bytes": "12 B",
"file_name": "test.csv",
"sys_updated_on_display": "2025-11-25 13:43:18",
"sys_created_by_display": "System Administrator",
"canWrite": true,
"sys_updated_on": "2025-11-25 02:43:18",
"table_name": "sc_cart_item",
"sys_id": "6b41c6ab83ddb210557ff0d6feaad3a9",
"content_type": "text/csv",
"size": "12 B",
"sys_created_on": "2025-11-25 02:43:18",
"canDelete": true,
"table_sys_id": "99a7792f83ddb210557ff0d6feaad3a5",
"state": "pending",
"sys_created_by": "admin",
"trackByKey": "6b41c6ab83ddb210557ff0d6feaad3a9pendingtest.csvundefined"
}
]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
if it's attachment type variable then it supports only 1 file and not multiple.
If you are talking about restricting file extensions/types then you can mention the file types it supports
If you are having 3 Attachment Type variables then to restrict 5MB you can add this in variable attributes like this
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Do you mean you want to restrict attachments on a catalog item to a maximum of three and a total restriction of max 5MB? I don't think you can robustly achieve this without customizing the catalog widget or creating a custom variable widget. You could use an attachment type variable x3 and the max_file_size attribute to restrict the size individually. If you can't reason with business about the requirements then it is achievable with widget development if you are comfortable with angularjs
One options is to do something server-side with the attachments - they are immediately added to sys_attachment when you upload them but they refer to the sc_cart_item table and a sys_id that is generated inside the sc catalog item widget and can be found in the data object.
Or client side in angularjs you can access information about the attachments in the scope of the sc catalog item widget. For example on the catalog page in the portal add an attachment from the bottom and paste this into the browser devtools console.
angular.element("#sc_cat_item").scope().$parent.attachments
//prints
[
{
"ext": "csv",
"size_bytes": "12 B",
"file_name": "test.csv",
"sys_updated_on_display": "2025-11-25 13:43:18",
"sys_created_by_display": "System Administrator",
"canWrite": true,
"sys_updated_on": "2025-11-25 02:43:18",
"table_name": "sc_cart_item",
"sys_id": "6b41c6ab83ddb210557ff0d6feaad3a9",
"content_type": "text/csv",
"size": "12 B",
"sys_created_on": "2025-11-25 02:43:18",
"canDelete": true,
"table_sys_id": "99a7792f83ddb210557ff0d6feaad3a5",
"state": "pending",
"sys_created_by": "admin",
"trackByKey": "6b41c6ab83ddb210557ff0d6feaad3a9pendingtest.csvundefined"
}
]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
if it's attachment type variable then it supports only 1 file and not multiple.
If you are talking about restricting file extensions/types then you can mention the file types it supports
If you are having 3 Attachment Type variables then to restrict 5MB you can add this in variable attributes like this
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader