Hello, I have a problem with a client script and a date “Incorrect date value”
I have the following script that should automatically set a date field “next maintenance” when the last maintenance is entered.
In Germany we have the following format dd.dd.yyyy But a database error tells me that it expects ‘2023-12-31T23:00:00.000Z’.
Anyone an idea how to work around this?
My Clientscript
frappe.ui.form.on('Testarena', {
letzte_wartung: function(frm) {
let letzte_wartung = new Date(frm.doc.letzte_wartung);
let intervall = frm.doc.intervall;
let naechste_wartung = new Date(frm.doc.naechste_wartung);
if (intervall == "Jährlich") {
naechste_wartung.setFullYear(letzte_wartung.getFullYear() + 1);
} else if (intervall == "Halbjährlich") {
naechste_wartung.setMonth(letzte_wartung.getMonth() + 6);
}
frm.set_value("naechste_wartung", naechste_wartung);
}
});
I’ve already tried to bypass it with a slice, but unfortunately that doesn’t work
function formatDate(date) {
var year = date.getFullYear();
var month = ("0" + (date.getMonth() + 1)).slice(-2);
var day = ("0" + date.getDate()).slice(-2);
return day + "." + month + "." + year;
}
I hope someone can put a head on the right path