07-22-2020 09:34 AM
Hi Team,
I have created one association in datalist content model as per below:
<associations> <association name="classi:picture"> <title>Picture</title> <source> <mandatory>false</mandatory> <many>true</many> </source> <target> <class>cm:content</class> <mandatory>false</mandatory> <many>false</many> </target> </association> </associations>
Document picker is working fine.
I want to allow only png and jpeg files to select.
I have tried the way suggested in https://blog.arvixe.com/add-new-form-validation-handler/
if (field.type == "hidden") { var fileName = field.value; }
I'm getting attached file noderef as an output.
How to get associated file name?
Thanks,
Hardik
07-23-2020 04:24 AM
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.
Explore our Alfresco products with the links below. Use labels to filter content by product module.