How to Fetch array from child-table data JavaScript?
Hi @Sagar_Bhogayata,
try something like this
var item_codes = new Array();
var qtys = new Array();
items.forEach(function(entry) {
if (entry.item_code != null) {
item_codes.push(entry.item_code);
qtys.push(entry.qty);
}
});
If you have a more specific question, please add more details, that helps to make the answer more specific This assumes you are looping through your subtable items and collects all item codes and quantities. Combine with a suitable trigger…
1 Like
Thanks @lasalesi
frappe.ui.form.on("Exporter analytics", "get_data_a", function(frm) {
var item = new Array();
exp_items.forEach(function(entry) {
if (entry.item_name != null) {
item_name.push(entry.item);
}
});
});
Here is exp_items is my child table
item_name is field name
Here is error
exp_items is not defined
I think i miss something
Hi @Sagar_Bhogayata,
sorry, I was too brief there. It has to be referenced to frm.doc.exp_items
, or you just load it with a line like
var items = frm.doc.exp_items;
2 Likes
what is actually field “get_data_a” is?
it’s a button field in that doctype, so added it as “get_data_a”
you can use any events from Form Scripts
1 Like