Page 1 of 1

File Upload Widget - Change Allowable MIME Types via JavaScript

Posted: Fri Feb 28, 2020 5:34 pm
by jleander
Hello, I was wondering if it is possible to change the file upload widget's allowable MIME types after the screen has loaded, based on a checkbox changing. I have had success allowing certain MIME types (using applyProperty for the "allowed type" fields and then reapplying the widget type), but am having difficulty getting the widget to allow all MIME types again (basically remove the "allowed type" property).

I've tried setting the value to "[all file types]" as that is what the designer shows as the default value, but that does not appear to be what it needs to be...is there a certain property value that I can use to get this to? I am on 6.2.1 if that has any implications on the answer.

I realize that if that is possible I have to handle the case where if I restrict the type after a file is already there. If there is a setting I can use for my question, is there a way to get a list of the MIME types for the files that are pending upload to determine if I need to clear the list based on restricting the MIME type?

Re: File Upload Widget - Change Allowable MIME Types via JavaScript

Posted: Fri Feb 28, 2020 8:44 pm
by Scott Klement
You can just right-click the property in the designer, and choose "remove property value", this will cause it to use the default.

The value "[all file types]" is not a valid value for this property, and isn't the default. I think you're seeing this in the property's help screen -- but the help screen isn't meant to consider this as a literal value, it's merely a note to let you know when the property is not set to anything, it'll allow all file types.

I have never tried to change it based on a checkbox on the screen, this seems like a very strange thing to do. Can you explain why someone would want to do this? If I understand your rationale, I might have some good suggestions on how to handle it. Without that, my general opinion is that the validation should be done on the server-side in the upload exit program.

I'm not sure the answer to the "list of pending file types" question. Again, can you explain the reasoning for this? Since I really don't understand the scenario, I'm not sure what to answer, here.

Re: File Upload Widget - Change Allowable MIME Types via JavaScript

Posted: Mon Mar 02, 2020 10:02 am
by jleander
Hi Scott, thanks for the quick reply.

We have a department that uploads documents into an archival system - for this purpose we don't restrict MIME type at all. However, certain documents that are archived can also be sent over for EDI processing (OCR to EDI essentially). Only certain record types have EDI functionality enabled, but for those that do allow it, we need to only allow PDF/XLSX document types. So, we have a checkbox on the screen that is only enabled for certain record types, and if it is checked I have to restrict the document types that we send to that process (and we still do archive the doc) - but if the checkbox is unchecked it acts as though it is just a normal unrestricted archival.

I was thinking I could have multiple instances of the upload box and flip visibility based on the checkbox, but then I'd have them losing the files they have in the upload widget pending upload. I do want to note that I was really just exploring if I had viable built-in options to give them or if I need to rethink my plan a bit. The ability to remove MIME type restrictions would have made this pretty simple - I was more hoping there was a secret sauce or reserved value that I'd be able to use towards that end already built in!

Re: File Upload Widget - Change Allowable MIME Types via JavaScript

Posted: Mon Mar 02, 2020 1:45 pm
by Scott Klement
I see. It may be possible to do what you're asking, but I haven't done it so don't know exactly how.

If you can't find a way, I would recommend submitting a support request to Profound Logic by contacting support@profoundlogic.com -- this way, we can look into it and get back to you. It might be necessary to modify the widget code, and submitting a request would make that possible as well.