Ready only Item code in Material Request using Custom script

Hey

I am trying to make Item code " Ready Only " in Material Request whenever user save it using Custom script but I unable make it read only. As we have approval workflow and I dnt integrity of item is changed in between approval chain Any help will be great

This my code

frappe.ui.form.on(“Material Request”, {
refresh: function(frm) {
// use the __islocal value of doc, to check if the doc is saved or not
frm.set_df_property(“justification”, “read_only”, frm.doc.__islocal ? 0 : 1);
}
});
frappe.ui.form.on(“Material Request”, {
refresh: function(frm1) {
// use the __islocal value of doc, to check if the doc is saved or not
frm1.set_df_property(“items”, “read_only”, frm1.doc.__islocal ? 0 : 1);
}
});
frappe.ui.form.on(“Material Request Item”, {
refresh: function(frm2) {
// use the __islocal value of doc, to check if the doc is saved or not
frm2.set_df_property(“item_code”, “read_only”, frm2.doc.__islocal === 1);
}
});
frappe.ui.form.on(“Material Request”, {
refresh: function(frm4) {
// use the __islocal value of doc, to check if the doc is saved or not
frm4.set_df_property(“requesting_for”, “read_only”, frm4.doc.__islocal ? 0 : 1);
}
});

try frm.set_read_only() to make everything read-only between your workflows.

btw, workflow gives an option to make it editable only a particular role.

I understand edit can be possible for particular role in workflow, But we will have many users with same role for eg Team Leader and any Team leader can change item if this editable

So can u please guide where u to use frm.set_read_only(), I am not good in coding , just learning from example and forum… Thanks

Make more specific roles

In the refresh method, if you need more help, hire a freelancer from the community.