function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Lookup window not closing after selecting the value in search result

I am trying to get the native lookup window to open up and when the value is selected needs to populate a hidden field.

I am able to call the lookup function, but when i select the value nothing happens, the lookup window doesnt close and value is not posted into the hidden field.


function showLookup(ctrlID,objKeyPrefix) 
        openLookup("/_ui/common/data/LookupPage?lkfm=ConvertwithInputs:pbmconvertInput:pbformmconvertInput&lknm="+ ctrlID +"&lktp="+objKeyPrefix,500);           

<apex:inputText id="vField_AccountName_lkid" value="{!s.selectedAccount}"/>           
<apex:image url="/s.gif" alt="Lookup (New Window)" styleClass="lookupIcon" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" onclick="javascript&colon;showLookup('ConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:' + jQuery(this).closest('tr').prevAll('tr').length + ':vField_AccountName','001')" title="Lookup (New Window)"/>


The url generated in the lookup used by the above window is

The url when you click on search result is

To test the urls i also had a standard lookup and the url generated is

The link on the search result for standard lookup is

The standard lookup for standard lookup field works fine

Where does the closing of lookup window happen?

Any pointers on what is happening while clicking of search result, where does the closing and assigning of value happen?





Did you make any progress with this, I am having the same issue. 




I experienced this issue when trying to call the native Lookup window through a custom button. I had the behavior set to URL, and this was causing the lookup window to open, but never close whenever a value was selected. To get around this, it appears that Salesforce accepts an openLookup JavaScript function. 

Therefore, I changed the expected behavior to JavaScript on my custom button, and put in the following code, which then allowed the Lookup Window to close whenever a value was selected. This button applies to Campaigns/Campaign Members, so you likely don't need all the parameters.