Unable to set date from JavaScript/route

Hi all,

I have a custom doctype (“Booking”), which I want to create a new record from a script. The script should fill the date. For this, I have the following code:

frappe.route_options = {
    "appartment": d.getAttribute("data-appartment"),
    "start_date": d.getAttribute("data-date"),
    "end_date": d.getAttribute("data-date") 
}
frappe.new_doc("Booking");

The data fields contain the reference and the date (as “2018-10-03”). The appartment parameter is correctly set, but date remains unset. I have tried various other formats, to no avail.

grafik

What am I missing?

check the output of - console.log(d.getAttribute("data-date")) before adding it in route_options. Might be it is not in correct format.

Thank you, @Sangram, but the parameter is populated. The error reproduces as well using

 frappe.route_options = {
    "appartment": d.getAttribute("data-appartment"),
    "start_date": "2018-10-05",
    "end_date": "05-10-2018 
}
frappe.new_doc("Booking");

Also, I have tried to pass a Date object from JS, all fail to pass the value…

Hello, i have the same problem. Spent a half day trying all thinkable options. No success.
If anyone has a solution to this problem i would appreciate it. :slight_smile:

Hi @Peter_G:

Try

frappe.new_doc("Booking", {
    yourField1: yourData1,
    yourField2: yourData2,
    yourField3: yourData3
})

Hope this helps.

Hi @avc , exactly this call i am using, but no success with setting the date.