When a link field is updated from code (using set_value() ) is there a way to trigger the link field to update as though the user had typed the input? Or an alternative to set_value() that will trigger the usual keyboard-entry events?
A scanned barcode value is being inserted from code (for a warehouse field) but the barcode doesn’t include the “company suffix”. If the field could be triggered to update after the scanned barcode value is inserted into the input field then the drop-down list should (normally) show only a single matching warehouse location which the user could then just hit enter to select. Or possibly the awesomplete methods could be used to insert the entry automatically.
However I can’t find a method that will trigger the usual events as though the value was keyed in manually. (The barcode reader is not the typical “keyboard wedge” type hence there are no keyboard events. )
use
frm.refresh_field(FIELD_NAME)
Doesn’t work for me.
ERPNext: v15.68.0 (version-15)
Frappe Framework: v15.73.0 (version-15)
frappe.ui.form.on("Batch", {
onload_post_render: (frm) => {
...
fld.$input.on('focus', () => get_barcode(frm, fld.df.fieldname));
...
# "get_barcode()" executes (async): `set_value(<fieldname>, <barcode>)`
...
warehouse: function(frm) {
frm.refresh_field('warehouse');
console.log("refresh_field(warehouse)");
},
}
is displayed in the “warehouse” input field, but no drop-down appears.
The message is printed to the console.
I would suggest,
Combine value of your barcode result and company’s abbreviation and then set value.
Not ideal for a few different reasons.
Very frustrating because the behaviour already built in to Frappe is very usable, just need a way to trigger it when the input is not from a keyboard.
The simplest work-around at this point seems to be to have the operator tap the space bar after scanning the barcode, but it would be good to eliminate the need for that if possible.