Autocomplete field

Hi, can you explain to me how does autocomplete works, like when i choose a customer when doing a quotation, the labels as price list, currency are autocompletion them selves, i wanted to make another label thats do autocomplete by choose the customer, but i dont know how does it work

@Dany_Carvalheiro, this are based in 2 features

add_fetch and set_df_property

  • add_fetch, works like the VLOOKUP of excel, to fetch a value from a referenced record
  • set_df_property change certain properties of a field, in this case (label)

These actions are made in JavaScript

1 Like

Steps:-

1.For that Go to ā€œCustomize Formā€
Enter Form Type=Item Price
Add new Row-
Label= Item Group
Type=Data
check option ā€œRead Onlyā€->Done
Drag that Row under ā€œItem Nameā€ row ,if you wantā€¦
click on ā€œUpdateā€ button

2.After that Go to ā€œCustom Scriptā€ form (search for "Custom Script)
Create ā€˜Newā€™
select Doc Type=Item Price

Write Script:-

frappe.ui.form.on(ā€œItem Priceā€, ā€œonloadā€, function(frm) {
cur_frm.add_fetch(ā€˜item_codeā€™, ā€˜item_groupā€™, ā€˜item_groupā€™);
})

Save Form.

You can refer following link also to read more things about custom script

http://frappe.github.io/erpnext/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/

thank you