I'm writing a suitelet and add the following field...
# suitescript
s
I'm writing a suitelet and add the following field form.addField({id: 'custpage_file',type : ui.FieldType.FILE,label : 'Choose file to import'}).isMandatory=true; When user click on it, I would like to see only the files with ".txt" extension. Is it possible ?
n
Don't believe so, I imagine you can add validation to it using fieldChange in a client script if you want to restrict it.
s
I haven’t tested this, but you might be able to attach a client script, and after document load, find the input tag with the name
custpage_file
and add an accept attribute to filter the selectable file types (
accept=".txt"
). Though, when I add an accept attribute on an input, it only grays out non-accepted files, making them un-selectable. It doesn’t eliminate them from the file select popup, so if the intention is to filter out visual clutter, this may not help. The user will still see other files, but not be able to choose them.