Is it possible to create an entry using custom script only?
Use case:
I need to generate Purchase Orders all at once on the Sales Order
Is it possible to create an entry using custom script only?
Use case:
I need to generate Purchase Orders all at once on the Sales Order
Sure…you can create the using the new_doc method.
You can reference an example here:
erpnext/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
Thanks! will try this one first.
My issue so far is that it will route me to that doc.
frappe.set_route("Form", doctype, name);
Hi, thanks but I dont want to get routed. I need to create multiple PO all at once.
you can Create hook on Sales Order and in py can differentiate how many sales order you want to create.
it’s not with javascript but i guess can solve your use case
you can use following script,
frappe.call({
method: "frappe.client.insert",
args: {
doc: doc // doc object
},
callback: function(r) {
//callback script
}
});
Thanks! it worked. But I have another issue now, It won’t create if I loop it.
I see, I wish we can do it in py. We are using ERPNext Cloud.
@Sangram any idea why it won’t work If I loop the items? Ex. I have 6 line items, I need to create 6 POs all at once.
I’ve tried to add ToDo by creating data obj arrays and map to function frappe.client.insert and it works. I tested in browser console.
let docs = [{"description":"test1","doctype":"ToDo"},{"description":"test2","doctype":"ToDo"},{"description":"test3","doctype":"ToDo"}];
const funcs = docs.map((doc) => {
frappe.call({
method: "frappe.client.insert",
args: {
doc: doc // doc object
},
callback: function(r) {
//callback script
}
});
});
Promise.all(funcs).then(()=> {
console.log("Done");
});
Thanks a lot! This approach works!