How to Hide child table fields in standard doctype

frappe.ui.form.on(‘Stock Entry’, {
refresh: (frm, cdt, cdn) => {
let doc = locals[cdt][cdn]
// console.log(doc)
// console.log(frm.doc.purpose===‘Material Transfer’)
frm.fields_dict[“items”].grid.set_column_disp(“source_warehouse_storage_location”, frm.doc.purpose ===‘Material Transfer’);
}
})

im trying to hide/show the child doctype fields based on stock entry type but it is not working.

P.S - I have a doctype js hook so the code is in my custom app not client script but anyways i check through client script it didnt work even then.

ERPNext: v13.19.0 (version-13)
Frappe Framework: v13.19.0 (version-13)

try this:

var df = frappe.meta.get_docfield("Child Table Name", "field_name", cur_frm.doc.name);
df.hidden = 1
1 Like

tried this but it works only before form is loaded

@OmarJaber this is working but it works only during setup,onload, refresh events my requirement is i need this field based on some conditions suppose from stock entry pupose and stock entry detail warehouse selected so if there is workaround so that I can use df even in child table fieldname events it would be very helpfull for me

Thank you

I’ve struggled with this too. The best solution I found came from this post. Using Sagar’s example, I’ve been able to trigger on refresh() events, and hide/show columns using some logic.

@brian_pond thank you let me try this out.

This did not work it worked fine in version 12 but then again version 13.19.0 its the same problem unable to hide fields on child table.

Hi @Yashwanth,

Please try in Depends On / Read Only Depends On permission

eval: parent.stock_entry_type == “Material Transfer”
OR
eval: parent.stock_entry_type != “Material Transfer”

Thanks!

i want it in script which user should not be able to see so, is there any other way

Thank you