Attach field type - Allowed file extensions

You can achieve this via the following Client Script:

frappe.ui.form.on("MY DOCTYPE", {
	refresh: function (frm) {
		const attach_field = frm.fields_dict["MY FIELDNAME"];
		attach_field.on_attach_click = function () {
			attach_field.set_upload_options();
			attach_field.upload_options.restrictions.allowed_file_types = [
				"application/xml",
				"text/xml",
			];
			attach_field.file_uploader = new frappe.ui.FileUploader(attach_field.upload_options);
		};
	}
});

Tested on develop / v16.

7 Likes