Custom script not working in v11 , but works in v10

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");

}

})

Does the console log show the changes?

Hi, i have the same issue on custom script in version 11, i am trying to pull tax_id from customer to quotation. frappe.get_value() nor cur_frm.add_fetch() works but version 10. Anyone??

Hi @brian_breez,

To fetch Tax id from customer to quotation, you can make use of the “Fetch from” option.

Create a custom field in the quotation doctype as shown in the below image and then save the form.

After saving the form, reload your account once.

When you select the customer in the quotation, it will fetch the tax id from customer doctype.

Hope this helps.

Regards,
Sujay

1 Like

I have tried that but no luck, i am using v11

@brian_breez

In the fetch from column type party_name.tax_id instead of customer.tax_id and uncheck fetch if empty.

This should work.

1 Like

It worked thanks