how to get an item based on it’s number .?
i am trying to do this in stock Reconciliation .
i added a custom ‘Link’ field in stock Reconciliation Item doctype . How can i get the only item attached to this number ?
any help please ?
Hi,
You need to make a script for this, you can try the below scripting:
frappe.ui.form.on('Stock Reconciliation Item', {
item_number: function(frm, cdt, cdn) {
const row = locals[cdt][cdn];
if(row.item_number) {
frappe.db.get_value('Item', {'item_code': row.item_number}, 'name', function(data) {
frappe.model.set_value(cdt, cdn, 'item_code', data.name);
});
}
}
});
This script monitors the custom “Link” field (named “item_number”) in the Stock Reconciliation Item doctype and responds to changes made to it. Upon modification, it employs the frappe.db.get_value()
function to retrieve the name of the item associated with the item code entered in the custom field.
Once the item name is obtained, the script leverages the frappe.model.set_value()
function to assign the item code value to the “item_code” field of the current row.
Hope this will help you out.
Thank you.