Is there a way i could create a clone of current item being added, update few fields and add a new item through custom script?
there is a method called, frappe.new_doc is this to create a new doctype? or can i use it to add an entry to my existing doctype “item”.
Update
i am using the below code to acheive the above
cur_frm.cscript.on_submit = function(frm) {
var newdoc = frappe.new_doc(“Item”);
newdoc.item_code = “testing”;
newdoc.item_group = “Mobiles”;
newdoc.flag.ignore_mandatory = True;
newdoc.insert();
}
but i am getting the following error in the console :
TypeError: newdoc is undefined
Update
I just tried printing newdoc using
newdoc=frappe.new_doc(“Item”);
msgprint(newdoc);
I see the message undefined. y is it undefined?
Any resolutions?
Thanks
Hi @Sangram
I used the following code
cur_frm.cscript.on_submit = function(frm) {
var d = frm.add_child(“Items”)
d.item_code = “testing”
d.item_group = “Mobiles”
frm.refresh_fields(“Items”)
}
But i got this error “TypeError: frm.add_child is not a function”