ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Custom script not working in v11 , but works in v10


#1

This code was working in v10
What is the problem?

frappe.ui.form.on(“Attendance”, {
to:function(frm, cdt, cdn){
var d = locals[cdt][cdn];
var hours=minutes=seconds=total=0
if(d.from && d.to)
{
var startTime=moment(d.from, “HH:mm:ss”);
var endTime=moment(d.to, “HH:mm:ss”);
var duration = moment.duration(endTime.diff(startTime));
var hours = parseInt(duration.asHours());
var minutes = parseInt(duration.asMinutes())%60;
var seconds=parseInt(duration.asSeconds())%60;
console.log(hours + ’ hour and ‘+ minutes+’ minutes.’ +seconds+‘second’);

}
	frappe.model.set_value(cdt,cdn,"total",hours+":"+minutes+":"+seconds);
	frm.refresh_field("total");

},
from:function(frm, cdt, cdn){
var d = locals[cdt][cdn];
var hours=minutes=seconds=total=0
if(d.from && d.to )
{
var startTime=moment(d.from, “HH:mm:ss”);
var endTime=moment(d.to, “HH:mm:ss”);
var duration = moment.duration(endTime.diff(startTime));
var hours = parseInt(duration.asHours());
var minutes = parseInt(duration.asMinutes())%60;
var seconds=parseInt(duration.asSeconds())%60;
console.log(hours + ’ hour and ‘+ minutes+’ minutes.’ +seconds+‘second’);

}
	frappe.model.set_value(cdt,cdn,"total",hours+":"+minutes+":"+seconds);
	frm.refresh_field("total");

}

})


#2

Does the console log show the changes?