Automatically Setting Focus to the Search Textbox in Lookups in Infor CRM Web

An annoyance I’ve always had when using the Infor CRM (Saleslogix) Web client is that in lookup dialogs the textbox where you type in a search value is not focused. You can’t just open a lookup and start typing. You have to first click into the textbox, then type in your search value. In my opinion this textbox should always be focused by default, allowing you to just start typing. Fortunately, it’s easy enough to change this behavior with some custom Javascript.

Here’s the code to change that behavior in all Lookups. I should add, this also changes this behavior in the search lookup in groups as well¬†👍🏻¬†(the dialog that shows when you click the magnifying glass icon in the top left of the groups list).

], function (
) {
    aspect.after(SearchConditionWidget.prototype, 'startup', function() {
        var self = this;
        var intId = setInterval(function() {
            if (self._valueBox) {
                var setFocus = function() { self._valueBox.focus(); };
                setFocus(); setTimeout(setFocus, 200);
        }, 100);

What this code is doing is it wires up some code to fire after the SearchConditionWidget is created (that is the widget that produces the field, operator, & search value controls in the lookup dialog). Once that widget is created, it waits until the search textbox is actually created (the widget itself executes a simulate to create the controls, so it needs to make sure that is actually done and the controls are added to the dom). Then, it sets the focus to the textbox. Note, the reason why it sets the focus, and then uses setTimeout to set it again in 200 milliseconds is because a dojo dialog will automatically attempt to set focus to the first focusable element (with tabindex=0). So, just in case the timing of that steals focus again, we do it a second time to be sure.

Here’s what that looks like when you have that code in place. Notice how the cursor always is set in the search textbox, just as you’d expect it to be.

Much nicer.

To use the code above, I would recommend using our free Custom Loader Module. Once, that is installed, go to the SlxClient portal and select the SupportFiles tab, open the Custom\Modules folder. Then create a new folder named “Lookups” and create a file named “main.js” inside of that and paste in the code from above. If you’re not using the Custom Loader Module (really, you should be. It makes things so much easier), then you’ll need to wire up the code above in the base.master (or just add it in there enclosed in script tags).


Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.


  1. Hi,
    Very nice one. Like to see the focus directly in the edit box.
    This should be part of the core product.
    Did you come across a solution to set the operator to contains if the user enabled this option in the user profile?
    Currently this is only reflected in the group lookup search.

    • Hi Alexander. That’s a great idea. I’ll have to give that one a try.

    • Hi Ryan, did you had time to look at how to get this working in groups?

    • Hi Alexander. This (setting the focus to the box you type in) does work in groups and in lookup dialogs. Not sure if you’re referring to your previous comment about changing the operator. I do have code that does that as well, but can’t remember if I have posted that on our website yet.

  2. Hi Ryan, well In 8.3 and 8.4 it seems that if your code is loaded it sets focus always when I am using lookup controls on forms. But if I am in a list view and click the search button it is still focussing the list bo where yu can select the field you want to search from. The code to set the operator to the same you set in list views would be also interesting. So if you can post or mail it, I will be very happy.

    • Hi Ryan;
      I come back to you to know if you have found a solution to be able to define the operator Contains by default in a control lookup with version 8.4.
      With version 7.5.4, we could do it by modifying the file Sage-Controls-Lookup.js but that’s no longer the case …
      Thank you in advance for your answer !

  3. Mygush,

    I do have a way to do that in current CRM but I’ve not yet written it up in a blog post. I’ll add it to my list of topics to write. What I do is add code using dojo’s aspect.after on the Sage/UI/SearchConditionWidget module’s _setToDefaultOperator function and set this._operatorSelect.set(‘value’, ‘gt’); to the operator I want (in that example I am setting it to greater than, but any sdata operator will work there as long as it is a valid operator for the field type)



Leave a Reply to Ryan Farley Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!