Fetch doctype field with display depends on problems

Dear All Users,

I try to create a doctype that fetch another doctype field. But the code seem’s does not work. I am not a programmer so no basic programming at the moment :slight_smile:

Here is my scenario:

  1. I made a new doctype called “The Gates” which consist of 64 doctype. The doctype structure is simple, just like this:

  1. I made a second doctype called Advanced Class Module 3 Prinsip 1P with the below structure:

  2. I made a field on the Advanced Class Module doctype called “Energy Gates”

  3. I then made another field on the Advanced Class Module doctype called “Gates 01” which is a “check” field that is supposed to fetch the data if checked from “Energy Dates” doctype, with naming series “Gates 01”:

But the result is an error on the depends on:

Here is my codes:

Blockquotefrappe.ui.form.on("EnergyGates”, {
Refresh: function(frm)
{
frm.add_fetch(“energy_gates_main”, “text_editor_1”,” text_editor_1”);
}
});

and here is my Display Depends On code:

Blockquoteeval:doc.name == ‘Gates 01’

Any one can help me in solving this simple issue? heheheh

Thanks in advanced for your helps…

@cyberdee you have use the fieldname of the doctype “energy_gate_main.fieldname of the Gates doctype” this should entered in fetch from. remove other codes.

could yu help me with the coding? I have no coding experience so I am purely blank on this… I just copy paste what I learn from the erpnext web :grin:

What is the fieldname you want to fetch from The Gates doctype with fieldtype

text_editor_1

Enter this energy_gates_main.text_editor_1 in fetch from.

let me try this…

After this go to the doctype and select the drop down name in Energy Gates while selecting the value will be fetched.

Noted. Also, how if I would like to get or fetch based on a specific The Gates doctype file? There are 01 to 64 file on the Gates, I would like to fetch for example: Gates 01 -> automatically the field on the Advanced Class Module is fetching only the Gates 01 ext_editor_1 field. I must use Display Depends On right?

No. you have linked the gates doctype in new doctype there you will select the name of gates, so while selecting that you text editor value will be fetched.

Eg : If you select
Gates1 then you get text editor of gates 1

That is another problem I need to solved… I need the check field will automatically fetch (only if it was being checked) the spesific Gates file. So if user check Gates 01, it will automatically fetch the text_editor_1 field from Gates 01 only.

Btw the above solution given does not work. See above result.

Could you explain what are you trying to achieve… so that i can explain in clearly.

So here is what I am trying to achieve:

  1. There are 64 document on the doctype called “The Gates”

  2. I would like to fetch the text_editor_1 field from a spesific “The Gates” document using a checkbox field on another doctype called Advanced Class Module. But the fetch must be filteres depends on the The Gates name/naming series. So if user clicked the checkbox Gates 01 at Advanced Class Module doctype, it will automatically fetch the text_editor_1 field from the Gates 01 document. Same goes if user clicked other number such as Gates 03, it will automatically fetch text_editor_1 field from Gates 03 document from “The Gates” doctype. Since it has 64 document at “The Gates”, it a bit confusing for me to fetch one by one using the checkbox as a filter…

you can take referance from this :- https://www.youtube.com/watch?v=f4gPxUay7v0 go on 2:24,and add in “depends on” :-Eval:doc.fieldname == 1 or Eval:doc.fieldname == 0 , of Doctype2’s field.

using both of this ,you can execute it