Hi,
I’m trying to get the item code field in a child table to trigger the fetches when I change the value through JS. The use case is showing a table of equivalent items with pricing with radio buttons. The button changes the value in the “item code” link field, but does not trigger any events and I can’t figure out what to call to refresh that field. Here’s where I am:
frappe.ui.form.on('Sales Order Item', 'item_code', function(frm, cdt, cdn){
var modal = locals[cdt][cdn]
var items = frappe.call({
method: "erpnext_controllers.erpnext_controllers.equivalent_sales_items.get_item_details",
args: {
"item_code": modal.item_code,
"customer": frm.doc.customer
},
callback: function(r){
$(frm.cur_grid.fields_dict['items_html'].wrapper).html(
frappe.render_template("equivalent_sales_items", {"items": r.message}))
$(".radio").click(function(e){
cur_frm.cur_grid.doc.item_code = e.target.id;
// works the same with modal.item_code = e.target.id
cur_frm.cur_grid.refresh_field('item_code');
cur_frm.trigger_link_fields(); // no change
});
}
})
});