I am confused with autocomplete field in the frappe form/doc. How to use it?
Any suggestion will be highly commendable.
2 Likes
I think you should be able to do so using Client Script.
Hi @Prasant_Pant:
Try this in client script
frm.fields_dict.yourfield.set_data(["one", "two"])
Hope this helps.
2 Likes
My implementation here
frappe.ui.form.on('Contact', {
refresh(frm) {
// Fetch the list of company names from the Contact list
fetchContactCompanyNames(frm);
}
});
function fetchContactCompanyNames(frm) {
frappe.call({
method: 'frappe.client.get_list',
args: {
doctype: 'Contact',
fields: ['company_name'],
order_by: 'idx'
},
callback: function (r) {
if (r.message) {
const companyNames = r.message.map(contact => contact.company_name)
.filter(name => name);
frm.fields_dict.custom_company_name.set_data(companyNames);
}
}
});
}
how will i use autocomplete filed in child doctype, how to set dynamically options for autocomplete field inside the child table