I am working with a Child Table, where the conditional statements work properly when I load a record into the child table. However, now I want to set a child table field as read-only. Please help.
frappe.ui.form.on("Asset List", {
form_render(frm, cdt, cdn) {
let child_doc = locals[cdt][cdn];
let dispatchedStatus = child_doc.dispatched_status;
let fieldname = "dispatched_status";
if (dispatchedStatus !== "Pending") {
console.log("Not pending");
//code here for read only child table field "dispatched_status"
} else {
console.log("pending");
//code here for not read only child table field "dispatched_status"
}
},
});
@NCP
In my scenario, I have an “asset_list” containing multiple items, each with a “dispatched_status” field. The requirement is that once an item is dispatched, its “dispatched_status” should not be editable again. The “dispatched_status” field is a Select field with options [Pending, Dispatch, Self-purchase].
If I go with “depends_on” and set it to eval:doc.dispatched_status=="Dispatch", the field becomes read-only or disabled. However, if a user intends to dispatch but suddenly decides to set it as “Self-purchase”, it won’t work. That’s why I want the “dispatched_status” field to be read-only whenever it is loaded.