Restrict file extensions for File Attachment field type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 06:17 AM
Hello,
I have been looking for an attribute that could restrict the file extensions for the File Attachment field type on a table level, not on a global level (in order to only allow PDFs to be attached) but couldn't find any. Are you aware of any solution for this? Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 06:50 AM
Hello,
allowed_extensionsSpecifies a list of allowed file types. For example, allowed_extensions=txt;pdf.
Applicable variables: Attachment.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2022 06:57 AM
Hi @Musab Rasheed ,
I am talking about the File Attachment field type, not about the Attachment catalog variable. The allowed_extensions attribute doesn't seem to work on the File Attachment field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 11:49 PM
Hello,
Have you find the solution for your issue ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2024 09:36 PM
To restrict file extensions for attachments, you'll need to approach the problem from a server-side perspective using a Business Rule or a Script Include that runs when an attachment is added to the sys_attachment table.
Here’s how you can do it using a Business Rule on the sys_attachment table:
Steps to Restrict File Extensions for Attachments
Create a Business Rule:
- Navigate to System Definition > Business Rules.
- Click on New to create a new Business Rule.
Configure the Business Rule:
- Name: Give it a meaningful name (e.g., Restrict File Extensions).
- Table: Select sys_attachment as the table.
- When: Select before for when you want the rule to run.
- Insert: Check the Insert checkbox, as we want the rule to run when a new attachment is inserted.
Add the Script to the Business Rule:
(function executeRule(current, previous /*null when async*/) {
var validExtensions = ['pdf', 'jpg', 'png']; // List of allowed extensions
var fileName = current.file_name.toLowerCase();
var fileExtension = fileName.split('.').pop(); // Get the file extension// Check if the file extension is not in the list of allowed extensions
if (validExtensions.indexOf(fileExtension) === -1) {
gs.addErrorMessage('Invalid file type. Only ' + validExtensions.join(', ') + ' are allowed.');
// Abort the attachment insertion
current.setAbortAction(true);
}
})(current, previous);