How to create Custom script to fetch my customize table to sales invoice item
i mean , i create doc. and this doc contain a table witch have item , item name , rate , and amount
so how can i fetch them to sales invoice by click on specific button
also a script for this : hello guys , in Journal Entry Template i can add a routine Ledger so i add to the table in this doc. Branch,cost center , but when i select my Journal Entry Template it dosent fetch cost center and branch
NCP
June 12, 2023, 6:21am
2
Hi @Qasrawii986 ,
Here we share the syntax of fetch the custom doctype child data in sales invoice.
frappe.ui.form.on("Sales Invoice", {
refresh: function(frm, cdt, cdn) {
frm.add_custom_button(__("Get Custom Child Table Details"), function() {
frm.clear_table("items");
frappe.call({
method: "frappe.client.get",
args: {
name: frm.doc.custom_parent_doctype_id,
// please set you custom doctype id/name in name field
doctype: "Custom Parent DocType Name"
},
callback(r) {
if (r.message) {
for (var row in r.message.custom_doctype_child_table_fieldname) {
var child = frm.add_child("items");
var rmi = r.message.custom_doctype_child_table_fieldname[row];
frappe.model.set_value(child.doctype, child.name, "item_code", rmi.custom_child_table_fielname_of_item_code);
frappe.model.set_value(child.doctype, child.name, "item_name", rmi.custom_child_table_fielname_of_item_name);
frappe.model.set_value(child.doctype, child.name, "description", rmi.custom_child_table_fielname_of_description);
frappe.model.set_value(child.doctype, child.name, "qty", rmi.custom_child_table_fielname_of_qty);
frm.refresh_field("items");
}
}
}
});
});
}
});
Please set the doctype, field name, and child table field name according to.
Learn Custom script examples.
I hope this helps.
Thank You!
1 Like
NCP
June 12, 2023, 10:03am
3
If you want to learn the Client script, then please attend the session on 14th June @ 2.30PM IST.
Hey Everyone !
The Official Build With Hussain Website is Live!
ICYMI, I built the website buildwithhussain.dev live in Episode 5 and 5B of the series. Check out the shiny new website for Build With Hussain. Don’t forget to register to stay notified about all the upcoming episodes, Frappeverse goodies, and more!
Up Next: JS Essentials & Client Scripts!
In this week’s episode of Build With Hussain (14th June @ 2.30PM IST), we will start by learning how JavaScript fits in the whole equatio…
1 Like