Child Table twice in the form? + filter on child table

Hi there,

2 questions for the price of one:

  1. Could you please confirm that a child table can not be added twice in a DocType ?
    I did the experience and no added line would save.

  2. Let’s say I have a Doctype called Member. Let’s say I have a child table which Doctype is called Member Relative.
    Its table field inside the Member Doctype is set to relative.
    The Member Relative Doctype has a field called type.
    How do I do to have in the relatives table all data linked to my corresponding parent but with type being filtered to something I chose?

I did many tries, unfortunately with no success.

Many thanks for your help!


Hey mate

  1. No you can not use the same child table twice in a doctype. Workaround: Create a duplicate child doctype
  2. Question and explanation do not make sense, try to explain in another way. However, you could use client scripts to automatically populate doctype fields and/or child doctype fields based on values from another doctype fields and/or child doctype fields.


Sorry for not being clear. So as I say to my apprentices: draw down your issue!

Here is the code I wrote down with the help of what I found on documentation and forums.
The idea is to have the child table filtered on type=‘A’

frappe.ui.form.on("Member", {
	refresh: function (frm) {
		frm.fields_dict['relatives'].grid.get_field('Member Relative').get_query = function(doc, cdt, cdn) {
			return {
				"filters": {
					"type": 'A'

I think the problem is with the field name you use the field label: member_relative
frm.fields_dict[‘relatives’].grid.get_field(‘Member Relative’).get_query

Thanks, unfortunately, it does not work either.

I have also tried what is proposed in the doc

// set filters for Link field item_code in
// items field which is a Child Table
frm.set_query('item_code', 'items', () => {
    return {
        filters: {
            item_group: 'Products'

With that code:

frappe.ui.form.on('Member', {
 	onload: function(frm) {
        frm.set_query('Member Relative', 'relative', () => {
           return {
                filters: {
                    type: 'A'

Unfortunately it does not work either.