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
prady-cmprady-cm 

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

https://c.na15.visual.force.com/_ui/common/data/LookupPage?lkfm=ConvertwithInputs:pbmconvertInput:pbformmconvertInput&lknm=ConvertwithInputs:pbmconvertInput:pbformmconvertInput:pbsmconvertInput:pbspbtable:0:vField_AccountName&lktp=001

The url when you click on search result is

https://c.na15.visual.force.com/_ui/common/data/LookupResultsFrame?lktp=001&lknm=ConvertwithInputs%3ApbmconvertInput%3ApbformmconvertInput%3ApbsmconvertInput%3Apbspbtable%3A0%3AvField_AccountName&lkfm=ConvertwithInputs%3ApbmconvertInput%3ApbformmconvertInput#

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

https://c.na15.visual.force.com/_ui/common/data/LookupPage?lkfm=ConvertwithInputs%3ApbmconvertInput%3ApbformmconvertInput&lknm=massConvertwithInputs%3ApbmconvertInput%3ApbformmconvertInput%3ApbsmconvertInput%3Apbspbtable%3A0%3Aj_id7&lktp=001&lksrch=

The link on the search result for standard lookup is

https://c.na15.visual.force.com/_ui/common/data/LookupResultsFrame?lktp=001&lknm=ConvertwithInputs%3ApbmconvertInput%3ApbformmconvertInput%3ApbsmconvertInput%3Apbspbtable%3A0%3Aj_id7&lksrch=&lkfm=ConvertwithInputs%3ApbmconvertInput%3ApbformmconvertInput#

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?

Thanks

brady_dhbrady_dh

Hi, 

 

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

 

Thanks

Je

MikeyJamJamsMikeyJamJams
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.

openLookup('/_ui/common/data/LookupPage?lkpr=00vf0000004Sh6f&lktp=701&enableScopes=1&addToCampaign=1&isCMClone=1',670,'1','');