I'm trying to code a function in ClientScript that copies a record from a DocType called "ProjectEmployee". The first step would be to create an empty instance of ProjectEmployee.
For that I tried using frappe.get_doc() and frappe.new_doc(), but to no avail.
Context information (for bug reports)
Output of bench version
erpnext 13.10.2
frappe 13.10.0
Steps to reproduce the issue
Create a ClientScript for a DocType
Code something like this, replace DocType-name "ProjectEmployee" with your DocType-name.
let newProjectEmployee_1 = frappe.get_doc("ProjectEmployee");
let newProjectEmployee_2 = frappe.get_doc({
doctype: "ProjectEmployee",
title: "New ProjectEmployee"
});
let newProjectEmployee_3 = await frappe.new_doc("ProjectEmployee");
debugger;
Enable Development Tools in your Browser, execute script and watch behaviour in Debugger and Browser
Observed result
newProjectEmployee_1 and newProjectEmployee_2 are null
frappe.new_doc(...) opened the quick entry dialog for the DocType
Expected result
newProjectEmployee_1 and newProjectEmployee_2 contain references to new instances of a DocType-record.
frappe.get_doc(...) should behave as documentations states (https://frappeframework.com/docs/user/en/api/document#frappeget_doc):
_frappe.getdoc(dict)
Returns a new Document object in memory which does not exist yet in the database.
frappe.new_doc(...) should create a reference to a new instance instead of opening the quick entry dialog for the DocType.
Even this is a handy feature to have, behaviour should be customizable by a optional parameter, e.g.:
Description of the issue
I'm trying to code a function in ClientScript that copies a record from a DocType called "ProjectEmployee". The first step would be to create an empty instance of ProjectEmployee. For that I tried using frappe.get_doc() and frappe.new_doc(), but to no avail.
Context information (for bug reports)
Output of
bench version
Steps to reproduce the issue
Observed result
newProjectEmployee_1 and newProjectEmployee_2 are null
frappe.new_doc(...) opened the quick entry dialog for the DocType
Expected result
newProjectEmployee_1 and newProjectEmployee_2 contain references to new instances of a DocType-record. frappe.get_doc(...) should behave as documentations states (https://frappeframework.com/docs/user/en/api/document#frappeget_doc): _frappe.getdoc(dict) Returns a new Document object in memory which does not exist yet in the database.
frappe.new_doc(...) should create a reference to a new instance instead of opening the quick entry dialog for the DocType. Even this is a handy feature to have, behaviour should be customizable by a optional parameter, e.g.:
The documentation of the Javascript API does not cover any of this, documentation should be extended.
Stacktrace / full error message
Additional information
OS version / distribution: Debian Buster, Browser: Firefox 78.12.0esr (64-bit) under Debian