Customise field value based on formula


I am trying to update a customise field “Due Days” field type duration with following script

frappe.ui.form.on(“Issue”, {
refresh: function(frm) {
frm.set_value(“due_days”, get_today() - frm.doc.opening_date);

but it is not working. Can anyone help where is the issue.

Change this to:

 frm.set_value("due_days",frappe.datetime.get_diff(frappe.datetime.get_today(), frm.doc.opening_date));

We’re using the frappe.datetime.get_diff function which returns the difference in dates in days.

1 Like