Hi there,
I am new with erpnext. I tried to start with simple scripts from examples.
this one is fine : i guess the “Task” is Doctype and “validate” is function.
// additional validation on dates
frappe.ui.form.on("Task", "validate", function(frm) {
if (frm.doc.from_date < get_today()) {
msgprint("You can not select past date in From Date");
validated = false;
}
});
read only is also working :
// make a field read-only after saving
frappe.ui.form.on("Task", {
refresh: function(frm) {
// use the __islocal value of doc, to check if the doc is saved or not
frm.set_df_property("myfield", "read_only", frm.doc.__islocal ? 0 : 1);
}
});
HERE is when I am struggling. After save or even better on the run i want to set simple value. For example OOTB field on Timesheet is field “note” and I want just to set there a value after save button is pressed so i expect to be :
frappe.ui.form.on("Timesheet", {
refresh: function(frm) {
frappe.model.set_value("note", "test");
}
});
But it’s not working. My next step is to set this on Timesheet detail but I even can’t set a value on timesheet. I know this should be super easy but I can’t make it work. can this be done only with client side script ?
Can you please help me?
Thanks,
Regards, Juraj