Prevent link field default events

Hello everyone,

I’m having a situation in my app. i have a link field associated with a doctype that has 8 millions of records.

When we click on the link automatically trigger a search function(in 8 millions records each time). in this case, i want that when you need to search something, you need to click the search icon.

I put that when you click the field, it opens the search dialog but the search function is executed too. Any suggestion?

(working with v4 here, apologies if this doesn’t apply to v5)

the search is driven by jQueryUI autocomplete, which has minLength parameter; this controls the minimum number of characters entered before it fires off the event, but the framework currently hardcodes a value of 0.

You could manually modify this value for your docfield in a custom script: something like

cur_frm.fields_dict.{docfield name}.$input.autocomplete("option", "minLength", 3);

now the autocomplete wont fire on my {docfield name}'s autocomplete until I type at least 3 characters. It’s not as easy for Links in a table, because those are rebuilt every time you open a row. You’d have to reapply the option on the render event for the table item.

As a more global option you could also write a custom sql search query to be called rather than the one automatically generated by the framework. You override the search endpoint via hooks.py

edit To more directly answer your question:

cur_frm.fields_dict.{docfield name}.$input.autocomplete("disable");

this would disable the autocomplete widget.

4 Likes

Thanks. It’s working. @jvermette