Hey,
How can we add a condition in a child table field to be read only based on the parent doctype field change ,can we do it directly by depends on or read only depends on or we have to apply clinet script or server script.
thankyou
Hey,
How can we add a condition in a child table field to be read only based on the parent doctype field change ,can we do it directly by depends on or read only depends on or we have to apply clinet script or server script.
thankyou
You can do Directly Using “Depends on” or “Read Only Depends on” by using parent.fieldname in condition in child table field, and for more control you have to write client script on Parent Doctype
we have tried this option but it works after saving the document
Yes, using “Depends On” or “Read Only Depends On” works only after saving or refreshing the form.
However, if you need the field to become read-only immediately when the parent field value changes, then you must use a Client Script, because it can update the child table behavior in real time.
frappe.ui.form.on("Sales Order", {
refresh(frm) {
if (frm.doc.is_assembly_list == 1) {
frm.fields_dict["packed_items"].grid.toggle_enable("qty", true);
} else {
frm.fields_dict["packed_items"].grid.toggle_enable("qty", false);
}
frm.refresh_field("packed_items");
},
is_assembly_list(frm) {
if (frm.doc.is_assembly_list == 1) {
frm.fields_dict["packed_items"].grid.toggle_enable("qty", true);
} else {
frm.fields_dict["packed_items"].grid.toggle_enable("qty", false);
}
frm.refresh_field("packed_items");
}
});
This works