Role wise child table field show readonly

Hello Community,!

can we set read-only on the field of the child table as per role?

Thanks in Advance.

Hi @Darshit_Patel,

Please apply custom/client script.

frappe.ui.form.on("Sales Order",{
    before_load: function(frm) {
        var df = frappe.meta.get_docfield("Sales Order Item", 'rate',frm.doc.name);
        if (frappe.user.has_role('Sales User') == 1) {
            df.read_only = 1;
        }
        frm.refresh_fields();
    }
});

We set the read-only field on the rate. so please check it.

Please set the doctype and field name which you use, your according.

Thank You!

before_onload: function(frm) {
        var df = frappe.meta.get_docfield("Task Calculation", 'start_date_and_time',frm.doc.name);
         if (frappe.user.has_role('Projects User') == 1) {
            df.read_only = 1;
        }
        frm.refresh_fields();
    },

@NCP
Same as but that is not work

Hmm :thinking:,

Please try in data field type, for testing.