Limiting file type on File attribute type

I have two areas where users can upload image files. One is a Property and it has been easy to restrict to pictures files (png,jpeg,jpg,tif,png) by editing the data type file for this.

However the other area is not so easy as this uses the File attribute. To restrict this I can use the settings on the Object, but when you do this the page still saves but doesn’t upload the file so the user doesn’t realise their image has not uploaded.

Is there any way we can restrict a file attribute in the same way as we can a File property or in some way stop them going forward until they have uploaded a valid picture file?

Hi @askelly ,

You’ve done the right thing of going into the File object’s settings and restricting the file types from there, that is how files types are restricted.

However, when you save the form where you’re uploading a restricted file, you should receive either a validation error stating the file is not allowed, or a banner message to state your file hasn’t been uploaded.

As you’re not receiving either, I would raise a Support Ticket for this.

Hope this helps :slight_smile:

Thank you, I will do this.

thinking about it, there is a message appearing at the top. Firstly the message to say the record has been saved, then the message to say the file upload has failed. The problem I have is that I need the file upload failing to stop them to be able to save the record. Once they have submitted a photo they don’t have access to the request any more. Is there a way to stop the submit button from working.

Hi @askelly ,

Good to hear that the banner is working :slight_smile: could be worded better, so i’ll ensure we have a bug raised internally to address this.

In the meantime, I can see the benefit in ensuring the form cannot be submitted. Ideally you’d want a validation error to be displayed to prevent submission of the form. Unfortunately this isn’t implemented as a Core feature, so i’d recommend raising this as an Idea.

However, it is possible to get around this problem using a Code Studio fragment validator. You could create a validator that checks the extension of the file, then returns true to allow submission, or false with the relevant error message.

Unfortunately, there is a bug outstanding at the moment for when you try to get the value of a file using Code Studio, so I can’t provide you any code just yet. Once this bug is resolved, i’ll potentially be able to provide you the exact code so that you can restrict the submission on a form based on file extensions.

Hope this helps :slight_smile:

Hi @askelly ,

Good news - We’ve implemented a change that will provide file validation on file attributes when a file is uploaded (before submission of the form). This will provide you with the validation you require within your forms, preventing form submission. We have implemented this as a patch in version 2021.2 onwards, so if you update to the latest patch, you will be able to use this feature.

Hope this helps :slight_smile:

1 Like

Hi Ann

How I solved the issue with blank file records existing after a failed file upload is by adding a rule which listens for the “Record created” event and then deleting the record if the “File” property is empty via a subset.

Hope this helps in the meantime if you are on an older version.


Thank you for your help Liam, luckily I was on a version where the patch has solved it but good to know there was a way around it if I needed it.

Thanks for all your help with this Ali. I now have it working and awaiting user testing. The patch did the job.

Fantastic news, glad it worked well for you :slight_smile: