Create a custom field with filters


Anyone please help me that if I’d like to create a custom field in “Customize” for example,
In Selling Module → Quote
Create a new row → ‘employee’

As the result, it will create a new text box that linked to Employee module, in the Quote form. If I’d like to click on the text box and list only employees in a specific department (e.g. Sales Department), how can I do?

Thanks so much in advance.

hi again @cipher you will have to user custom scrip for filtering for example:

    frappe.ui.form.on("Quotation", "refresh", function(frm) {
cur_frm.fields_dict['employee'].get_query = function(doc, cdt, cdn) {
	return {
			['Department', '=', 'Sales Department']

Please consider this first:

This scrips work for filtering a field under the main doctype in this case quotation.
and the filtered filed is called employee.

1 Like