Customize the Link field as dropdown select

How can I create this:


Instead of this:
image

The idea is to disallow to user fill some values that doesn’t exist in Link field

You will have to remove “create” permission for the user for that particular doctype. For that, goto Role Permissions Manager and select the doctype name. Then, for the particular role, unselect “Create” checkbox.
Hope this helps.

1 Like

Thank you for your answer, but I don’t properly explain the reasons of this case.
User can fill in this input field unexistable data. I want to give him a choice:

  1. Or you create the new user by Click on the “Create a new Customer”
  2. Or you select the existable Customer from list.

You can notice, that anyway you can fill in this input field something like “jklsjalljfdskajlj”
And continiue to create the doctype

@Artem,
You can try this,
JS File

function getTDSAccountDetails(){
	var qry = "select distinct(customer_name) from `tabCustomer`";

	frappe.call({
		method: "Method URL",
		args: {"qry": qry},
		callback: function (getCustomerJainDetail) {
			if (getCustomerJainDetail.message != undefined) {

				options = [];
				for (i = 0; i < getCustomerJainDetail.message.length; i++) {
					options[i]= getCustomerJainDetail.message[i][0];
				}

				cur_frm.set_df_property('fieldName', 'options', options);
				cur_frm.refresh_field('fieldName');
			}
		}

	});
}

Python File:

@frappe.whitelist()
def dbquery(qry):
	try:
		data = frappe.db.sql(qry)
	except:
		frappe.errprint(qry)

	return data

and make that field as select option instead of Link Field.

3 Likes