Try ERPNext Buy Support Partners Foundation

[Ask] Get List from Doctype Childtable on Another Doctype Childtable

Hi guys, have a great day and thank you for a great software.

I need help for some case.
I want to get a list from Doctype A childtable to be appear on Doctype B childtable as a selection
I’m a newbie in programing, and really appreciate for your help.
I attached the image below to make your understanding easier.

Once again, thank you.

do you just want this as a select field or as a link? if just select field, you can write a python code/ javascript code to fetch that table as a list and then pass it as select field options using df property

options_list = [opt1, opt2, opt3, op4]

frm.set_df_property('field_name', 'options', options_list);
1 Like

Thanks for replying, and how exactly phython or javascript code looks like that i need to write?

there are tons of post in forum on how to get data from doctype and child tables and how to manipulate the said data to fit your needs,


In Js

refresh: function(frm) {
 frm.set_query("triggerred_field_name", "childtable_name", function(frm, cdt, cdn) {
		var d = locals[cdt][cdn];
		return {
			query: 'apps.apps.doctype.doctype_name.doctype_name.query_name',
			filters: {
				dependant_field_name: d.dependant_field_name

In Py

def query_name(doctype, txt, searchfield, start, page_lan, filters):
dependant_field_name= filters.get('dependant_field_name')
result = frappe.db.sql("""
	SELECT distinct
		`tabSource Doctype (childtable)` a
		a.parent = '{0}'
return result

Thanks. Please close this thread.