Under a child table, for specific/single row, not able to make field required (Instead all fields in rows get required)


Under child table, Is there a way to set a field to required, let’s say Retirement Date field to be set as required, if only status=Retired

Well with the below code, the field is set as mandatory but for all the rows/records of the child table and not for any specific/single row.

For eg: if there are 10 rows, and I made status=retired in one of the row only, but then too the retirement date for all 10 rows will become required.

frappe.ui.form.on("Child Doc Name", "status", function (frm, cdt, cdn) {
    let child = locals[cdt][cdn];
    let grid_row = frm.fields_dict['items'].grid.grid_rows_by_docname[child.name];
grid_row.toggle_reqd("retirement_date", child.status=="Retired");