Autocomplete field property exmaple needed if any?

I am confused with autocomplete field in the frappe form/doc. How to use it?
Any suggestion will be highly commendable.

Hi @Prasant_Pant:

It seems work like a mixing between Select and Link field …

Hope this helps.

2 Likes

@avc
It is not dynamic. Can we do from client or server script?

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