Customise dropdown box

hello,

I have one dropdown field in which i want only that employee name who has " ‘xxx’ or ‘yyy’ or ‘zzz’ " designation.
how can i implement this??

thnx,
Nishant Jariwala

Yes, Please read this

https://kb.frappe.io/kb/customization/overriding-link-query-by-custom-script

Thnx @kolate_sambhaji ,

But i don’t want to use list because through list only employee id appear on dropdown box like this.

But i require Employee name instead of employee id for this particular field so how can we do this??

only for this i use dropdown but i am unable to fill dropdown .
if you know any way for this please suggest me.

You can query the employee names and update the options property of your Select control

var employees = [
  {"label": "employee name", "value": "employee_id"}, {..}, {..} ]

cur_frm.set_df_property("employee_name", "options", employees);
2 Likes

Thnx @rmehta,

Great!!
it seems what i am looking for.
I’ll try this & let you inform… :smile:

1 Like

thnx,
It’s working like charm… :blush:

Hi,

I am looking for the same functionality, I tried with sample as below for link field on form onload

var mname = [ {“label”: “test_name”, “value”: “test_id”} ];

cur_frm.set_df_property(“master_name”, “options”, mname);

But throwing following error while click on the select field


DocType [{“label”:“test_name”,“value”:“test_id”}] not found

The resource you are looking for is not available

I am new to ERPNext, may be doing something wrong. Please advice on this.

Thanks in advance.

@kolate_sambhaji link is broken

https://frappe.github.io/frappe/user/fr/guides/app-development/overriding-link-query-by-custom-script.html

i think there is an issue with URL forwarding, but always you will find it here

frappe : http://frappe.github.io/frappe/user/
erpnext: http://frappe.github.io/erpnext/user/manual/

1 Like

Hi,

I was trying this functionality and hit similar error :

At the dropdown of Employee in Leave Application, I am trying to show the company the employee belongs to. Currently, it is just a dropdown of Employee ID and Employee Name. So, I have tried :

  1. company in Search Fields in Employee Customize Form - did not work.
  2. Tried the following code via Custom Script and hit the error above :

var employees = [
{“label”: “Company”, “value”: “company”} ]
cur_frm.set_df_property(“employee”, “options”, employees);

Kindly advice how I could achieve showing company in the dropdown of Employee in Leave Application.
Thanks in advance.

@rmehta can please tell me where write this code it is better if you could give me a link

You can add custom field of Company right?? Y u need script??