frappe.ui.form.on(‘Emp’, {
refresh(frm) {
// your code here
cur_frm.cscript.custom_delivery_date = function(doc, cdt, cd){
cur_frm.set_value(“date_of_retirement”, frappe.datetime.add_years(doc.date_of_birth, 60));
};
}
});
@silocoegypt cur_frm.cscript.custom_x
is a legacy API pattern and is already deprecated!
Also, there’s no need to write this code inside the “refresh”, you can do this
frappe.ui.form.on('Emp', {
'refresh': {},
'delivery_date': frm => {
frm.doc.date_of_birth && frm.set_value('date_of_retirement', frappe.datetime.add_years(frm.doc.date_of_birth, 60));
}
})
Keep in mind that this will be triggered on the change of delivery_date
field, and only will execute of there’s an value at date_of_birth
due frm.doc.date_of_birth &&
verification prefix
1 Like
thanks for your help