Dear Community,
In Purchase Order in table when we select Item Code (link) it shows all item and end of the the list “Create new item” show i need create item filter comes in top of list.
I tried code it need to adjust any line
frappe.ui.form.on('Purchase Order Item', {
item_code: function(frm, cdt, cdn) {
const row = frappe.get_doc(cdt, cdn);
// Small delay to allow ERPNext to populate the dropdown list
setTimeout(() => {
const linkField = frm.fields_dict['items'].grid.get_field('item_code');
// Access the dropdown options directly and manipulate the DOM
linkField.$input.on("click", function() {
// Once clicked, reorder options to move "+ Create a new item" to the top
let dropdownOptions = linkField.$input[0].awesomplete._list;
let createNewIndex = dropdownOptions.findIndex(option => option.includes("+ Create a new Item"));
if (createNewIndex > 0) {
// Remove "+ Create a new item" from the current position and place it at the top
let createNewItem = dropdownOptions.splice(createNewIndex, 1)[0];
dropdownOptions.unshift(createNewItem);
// Update the list in awesomplete
linkField.$input[0].awesomplete.list = dropdownOptions;
}
});
}, 200); // Adjust delay if needed
}
});
Kindly help to solve the issue
Thanks in ADvance