How to fetch checkbox in a table from a doctype

Hi,

How to fetch checkbox automatically from a doctype into child table. I have a checkbox in doctype “Quality Inspection Paramater” and I want it to be fetched into Table Doctype "Quality Reading.

Here is the code I tried :

 frappe.ui.form.on('Quality Inspection Reading', {
   refresh: function(frm) {
     cur_frm.add_fetch("quality_inspection_parameter", "manual_inspection", "manual_inspection");
   }
});

Thank you for your help!

Hi @FredericVerville,

Please apply it.

frappe.ui.form.on("Quality Inspection Reading",'refresh', function(){
    for (var i =0; i < cur_frm.doc.quality_reading.length; i++)
    {
        cur_frm.doc.quality_reading[i].manual_inspection = cur_frm.doc.manual_inspection;
	}
	cur_frm.refresh_field('quality_reading');
});

Please set your table name and field name according to.
Then reload and check it.

Thanks.

Hi @NCP

Thank you for your quick answer! Where do I put the “quality_inspection_parameter” doctype in your code? It is the doctype where the value is fetched.

Doctype where Checkbox Value is fetched = Quality Inspection Parameter
Parent Doctype where the Table is = Quality Inspection
Table where value is put = Quality Inspection Reading

Thank you!

Hi @FredericVerville
You can do it without coding, just use fetch from [link_field.checkbox_field]
for example I have 3 doctype (Test1, Test2, Test3)

Test1 contain [fieldName - type]

  • name - Data
  • check - Checkbox

Test2 is child table type that contain

  • Name - Link for Test1 Doctype
  • Check - [name.check] here you use fetch from

Test3 is contain child table

  • test - Table for Test2 Doctype

Test1

Test2


Test3

That is what I did, but it is not working :

I found why it was not working, I don’t know why, but I needed to put :

specification.manual_inspection

instead of

quality_inspection_parameter.manual_inspection