Hi! Any one help me out of this one.
From the one doctype Am having a button while clicking the button it will create a new doctype using frappe.db.insert()
method. Now, Am fetching the value form one child table and send to the auto created child table, but I have given all this in Each so it’s creating every row in new doctype now i need all the rows in same doctype. I have attached a code and console log below , Kindly Help me out of this!
frm.add_custom_button(__("Approve"), function(){
frm.trigger('Approve');
frm.set_value('workflow_state',"Approved By Sales Manager");
frappe.msgprint("Approved By Sales Manager and send for block shipment.");
frm.refresh_field('workflow_state');
var a = frm.doc.name;
$.each(frm.doc.table_10, function(i, d) {
globalThis.triger = frappe.new_doc = ({
"doctype" : "Redirecting",
"link_1" : a,
table_2 : [{
q_block_no : d.q_block_no
},frm.refresh_field('table_2')]
});
frappe.db.insert(triger),
console.log(triger)
});
frm.save('Submit')
}).addClass("btn-success").removeClass("btn-default");
Console log:
Output of insert doctype:
every rows are getting insert in a new doctype, I need all the rows in one doctype.
Thank you.