i need how to change a filed type on child doctype to mandatory based on selection or check box and also how to change it to read only on save
You can use these function for your purpose:
to make field mandatory: frm.toggle_reqd(fnames, mandatory)
to make field read only : frm.toggle_enable(fnames, enable)
it does not work
could you share your code
Dear @Mohammed_Redha
i use this script to make field margin mandatory when select Final LG from filed type but it’s not working
ur_frm.cscript.custom_mandatory_filed = function(doc){
cur_frm.set_df_property(“margin”, “reqd”, doc.type==“LG Final”);}
could you please post the correct code
Thanks Mohamed For your quick response
this below script is working fine but only make margin filed mandatory when click save not immediate change filed color to red like for example in payment entry with payment mode cheque
cur_frm.cscript.custom_validate= function(doc){
cur_frm.set_df_property(“margin”, “reqd”,doc.type==“LG Final”);}
frappe.ui.form.on([DocType], {
[trigger]: function(frm) {
[function];
}
});
in your case
frappe.ui.form.on(‘Payment Entry’, {
custom_mandatory_filed: function(frm) {
frm.set_df_propertyset_df_property(“margin”, “reqd”,frm.doc.type==“LG Final”);
}
});
please look at this link :
https://github.com/frappe/frappe/wiki/Developer-Cheatsheet
SyntaxError: Invalid or unexpected token
sorry, try agin
frappe.ui.form.on('Payment Entry', {
custom_mandatory_filed: function(frm) {
frm.set_df_propertyset_df_property('margin', 'reqd',frm.doc.type=='LG Final');
}
});
Thanks Mohamed
but this script not working the above one i posted later is working but only when hit save so i need it when select Final LG change margin filed color to red like any other mandatory filed