Try ERPNext Buy Support Partners Foundation

Add fetch question

Hi
i want to ask about this cur_frm.add_fetch("employee_name", "date_of_join", "date_of_join");
after i select employee from my link field in my doctype it should appear at that time this (date of join)
now after i click on the filter for the employee it doesnt fetch the data

is there any problem in my custom script?

Refer to this page and see how the add_fetch works.

https://erpnext.org/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/custom-script-fetch-values-from-master

@kevingee
in the begining (cur_frm) does it belong to customer only or it is a general class?

You need to provide more information on your use case. More information on what you are trying to achieve.

@kevingee
there is a field in the employee file called (Department)
i make a new doctype called (Leave request during working hours)
also i already make a field link to the employee in the doctype
i want after i select one of the employee it gives me his department
i already create another field in the doctype called (Department)
thank you

If I understand you correctly…

You have a doctype called Leave request during working hours. On this doctype, you have a field which is linked to the Employee doctype. You have another field called department on new doctype. When you dropdown on the field displaying the employee, you want the department name to display in the department field after selecting the employee.

Is this what you want to achieve?

yes exactly this what i want to achieve

Assuming on the doctype Leave request during working hours, there are 2 fields

  1. employee (link field to Employee doctype)
  2. department

Create a new custom script. Select the doctype you want run the script on.

Then type this

cur_frm.add_fetch("employee","department","department");

The format is
cur_frm.add_fetch(link_field, source_fieldname, target_fieldname);

link_field = the field that will have the dropdown
source_fieldname = the field that you requirement the info from. In this case, department from Employee doctype
target_fieldname = the fieldname you want to display the fetched info. In this case, department on the Leave request during working hours doctype.

still not working

Provide screenshots of the list of fields under the custom doctype you created

you should make it in Delivery Note Doctype

@NMyshuk
i already make there but it is not showing

also it should be cur_frm.add_fetch("item_code","operation_section","operation_section");

@NMyshuk
still not working is there is another way to fetch the fields?

Which link field are you using to trigger the fetching??

item_code

No screenshot of that?

Provide all information regarding your difficulty so that members here can help. Currently, I cannot really tell what is working and what is not working.

Are there any errors being displayed? Any pop ups? All these help.

cur_frm is whatever form is loaded. You can use cur_frm for any doctype.