Updating date fields using a custom script inside frappe.ui.form.on

Good Day,
I am trying to update the from_date and to_date field in the salary structure form using a custom script. What I am trying to do boils down to this:

frappe.ui.form.on("Salary Structure Earning", "modified_value", function(frm, cdt, cdn) {
  frm.doc.from_date = '2014-7-1';
}

However this doesn’t seem to work. Any ideas?

Hi shantanubhadoria,

Considering you want to set from_date and to_date fields on salary structure on form loads, you have to do some modifications in your script.

  1. Currently you are accessing child table ie “Salary Structure Earning” instead access Salary Structure
  2. Put trigger on onload event instead of modified_value
  3. also check for __islocal to set values only to non saved form.

Use frm.set_value("from_date", "2014-07-01")

1 Like

Thanks, That was what I was looking for.