Trying to set autocomplete - Options for a child table, by using query output. whats wrong in below code is any other option to set the child table fields -options
sku_add: function (frm, cdt, cdn) {
frappe.call({
method: “logistic.utils.get_voucher_detail”,
args: {
‘agmtNo’: frm.doc.agreement_number,
},
callback: function (r) {
if (r.message) {
skuDetail = r.message
let options = r.message.map(item => ({
label: ${item.sku_code} - ${item.sku_name},${item.quantity})
,
value: item.name
}));
// Iterate through rows of the child table
(frm.doc.sku || []).forEach(row => {
let grid_row = frm.fields_dict.sku.grid.get_row(row.name);
if (grid_row) {
let field = grid_row.get_field('sku_code_autocomplete');
if (field) {
// Set the options for the Autocomplete field dynamically
field.df.options = options.map(opt => opt.label).join('\n');
field.refresh();
}
}
});
refresh_field("sku");
}
},
});
},