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
AnumcaAnumca 

How to display the LOOK UP in VF page

Hi All

 

 

             I need to display the LOOK UP in VF page without using Sales force Configuration.Its urgent

 

Please help me

 

 

 

Thanks & Regards

 

Anu...

 

LakshmanLakshman

Hi Anumca,

 

Design a page which will contain desired look up value. Add the look up button or image besides the field which you desire. Then on click of this button open this page by showModalDialogBox. Select the desired value from this modal pop-up and then pass a parameter to the parent while returning and close the modal pop-up. I hope you understood the concept. Let me know if you are facing any issues.

 

Regards,

Lakshman

Shashikant SharmaShashikant Sharma

Do you want to use salesforce native lookup window or want to create your own VFP. both are possible. let me know what you want

Shashikant SharmaShashikant Sharma

If you want to use native lookup then use this

 

Add this Script

 

<script>
    
      function showLookup(ctrlID,objKeyPrefix)
        { 
            openLookup("/_ui/common/data/LookupPage?lkfm=editPage&lknm="+ ctrlID +"&lktp="+objKeyPrefix,500);           
         }
</script>

 


 

 

 

<apex:pageBlockSectionItem id="pbsiID">
                    Field Label
                    <apex:OutPutPanel id="opAccountID">
                        <apex:inputText id="vField_AccountName" value="{!AccountNameForSearch}" style="width:150px"/>
                        <apex:inputHidden id="vField_AccountName_lkid" value="{!lookupAccountID}"/>
                        <apex:inputHidden id="vField_AccountName_lkold" value="{!lookupAccountNameForOld}"/>
                        
                        <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('pageID:formID:pageBlockID:pbsID:pbsiID:vField_AccountName','001')" title="Lookup (New Window)"/>
                    </apex:OutPutPanel>
                </apex:pageBlockSectionItem>

pageID:formID:pageBlockID:pbsID:pbsiID:vField_AccountName : Change this id to your vField controls id

 

'001' is Account objects Key Prefix , give your key prefix

 

Please ask if any confusion.

 

Otherwise you can crete your own custom lookup page, and open it using showModalDialog and reyurn values to parent window using window.return value.

AnumcaAnumca

Hi Shashikanth

              Thanks for the reply.

 

It is displaying Loolup symbol,not working the functionality.Can you please send me the code.

 

Thanks & Regards

Anu...     

 

 

Shashikant SharmaShashikant Sharma

Please send me your code where you used it , there must be some issue in ID where you used it.

AnumcaAnumca

Hi Shashikanth

 

  This is the Controller which I have used

 

public class accvflkpclass {

public string bdayNameForSearch{set;get;} 

 public string lookupbdayID{set;get;}

public string lookupbdayNameForOld{set;get;}

}

 

and Tha Page is

 

 

<apex:page controller="accvflkpclass">

<script>       

  function showLookup(CF00N90000001mmqK,a04)   

    {          

  openLookup("https://ap1.salesforce.com/_ui/common/data/LookupPage?lkfm=editPage&lknm=con4&lktp=a04&lksrch="+a04,500);    

               }

</script>

<apex:form >

<apex:pageblock >

<apex:pageBlockSection >

<apex:pageBlockSectionItem id="pbsiID">           

        Field Label             

      <apex:OutPutPanel id="opAccountID">

  <apex:inputText id="vField_AccountName" value="{!bdayNameForSearch}" style="width:150px"/>

  <apex:inputHidden id="vField_AccountName_lkid" value="{!lookupbdayID}"/> 

<apex:inputHidden id="vField_AccountName_lkold" value="{!lookupbdayNameForOld}"/>

<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('pageID:formID:pageBlockID:pbsID:pbsiID:vField_AccountName','a04')" title="Lookup (New Window)"/>         

</apex:OutPutPanel> 

</apex:pageBlockSectionItem>

</apex:pageBlockSection>

</apex:pageblock>

</apex:form>
 </apex:page>

 

Can you please see this code once & tell me whats wrong with it.

 

Thank you

 

 

 

Thanks & Regards

Anu......

Shashikant SharmaShashikant Sharma

Now what I meant was pageID:formID:pageBlockID:pbsID:pbsiID:vField_AccountName this should be the id for the control

vField_AccountName. Id for any control gets generated using hierarchy.

 

In your case page,form and other controls that are in it's hierarchy do not have id's,

 either you take syastem genereated id's like ik1 from your view source or give same ids as i hav give

 



<apex:page controller="accvflkpclass" id="pageID">

<script>       

  function showLookup(CF00N90000001mmqK,a04)   

    {          

  openLookup("https://ap1.salesforce.com/_ui/common/data/LookupPage?lkfm=editPage&lknm=con4&lktp=a04&lksrch="+a04,500);    

               }

</script>

<apex:form id="formID">

<apex:pageblock id="pageBlockID">

<apex:pageBlockSection id="pbsID">

<apex:pageBlockSectionItem id="pbsiID">           

        Field Label             

      <apex:OutPutPanel id="opAccountID">

  <apex:inputText id="vField_AccountName" value="{!bdayNameForSearch}" style="width:150px"/>

  <apex:inputHidden id="vField_AccountName_lkid" value="{!lookupbdayID}"/> 

<apex:inputHidden id="vField_AccountName_lkold" value="{!lookupbdayNameForOld}"/>

<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('pageID:formID:pageBlockID:pbsID:pbsiID:vField_AccountName','a04')" title="Lookup (New Window)"/>         

</apex:OutPutPanel> 

</apex:pageBlockSectionItem>

</apex:pageBlockSection>

</apex:pageblock>

</apex:form>
 </apex:page>

 

See the ids that i gave, please ask if any confusion

Sunil PalSunil Pal
Hi Shashikant Sharma

I am able to get the popup when I click on lookup icon but wheever I am selecting any of the data coming in that popup I am not able to close the popup and also the value is not selected in the input text.

Please if you have done something controller side provide us the detail so that we can also know the proper flow.

Buut ya it helps me lot ...Thanks for sharing