restrict file type selection for document picker

Showing results for 
Search instead for 
Did you mean: 
Active Member II

restrict file type selection for document picker

Hi Team,

I have created one association in datalist content model as per below:

				<association name="classi:picture">

Document picker is working fine.

I want to allow only png and jpeg files to select.

I have tried the way suggested in 

if (field.type == "hidden") {
        var fileName = field.value;

I'm getting attached file noderef as an output.

How to get associated file name?



1 Reply

Re: restrict file type selection for document picker

You cannot get any more meaningful data from the value in a validation handler within the client-side JavaScript code. You could perform a ReST call to the backend to resolve the value to the node data including mimetype / extension, but ReST calls being asynchronous, that would decouple you from the validation handler flow of execution and you could not influence the result of the validation anymore. There is technically already a parameter that can be used to restrict which elements can be selected in document pickers, and it is even supported by the default client-side picker component, but the default association form control provides no means to specify that option via the control parameters. You would have to create a custom variant of the association control template to pass that along - I have done so in two customer projects and it works quite well.