Fetch Array from child table data

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) {

If you have a more specific question, please add more details, that helps to make the answer more specific :wink: 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) {

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;

Thanks @lasalesi Its Work :v:

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