Example script for setting value won't work

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

Try using frm.set_value instead.

Thanks Nick,

i tried cur_frm.doc.note=“test” and it’s working.

I have one other problem , could you help me please ?

Timesheet doctype have child table called Timesheet Detail referenced as “time_logs”.
In Timesheet detail I have field “hours” and also field for each day in the week.

What I want to achieve is that when I enter values for each day , the value “hours” will be calculated based on days.

I found few examples here on the forum but it’s not working.

Do you have any idea?

Thanks,
Regards,
Juraj