How to make Chlid Table Filed Read Only based on Chield Table Selection Field

I want to set “Hotel Required” Field Read Only If I select “Return Journey” in “Journey Type” Field

I tried the below code:

frappe.ui.form.on(‘Booking Details’, {
journey_type: function(frm, cdt, cdn) {
var child_table = locals[cdt][cdn];
if (child_table.journey_type === ‘Return Journey’) {
frappe.model.set_value(cdt, cdn, ‘hotel_required’, ‘No’);
cur_frm.get_field(‘hotel_required’).grid.docfields[index].read_only = 1
} else {
frappe.model.set_value(cdt, cdn, ‘hotel_required’, ‘’);
cur_frm.get_field(‘hotel_required’).grid.docfields[index].read_only = 0
}
}
});

Its not working.

Hi @Abhishek1602,

First thing, if field is in listview then you can’t set the read_only field.
But your field is not in listview then you can set the field read_only.

Please update the above line.

frm.set_df_property('your_child_table_name', 'read_only', 1, frm.docname, 'hotel_required', child_table.name)

Please set your child table name and other field your according to.

Reference: Please check the whole post.

Thanks!