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
anvesh@force.comanvesh@force.com 

How to create Lookup icon for custom visual force page?

How to create  Lookup  icon for custom visual force page?

hitesh90hitesh90

Hi anvesh,

 

Below is the sample Visualforce Page as per your requirement.

 

Visualforce Page:

<apex:page  tabstyle="Account">
<script>
    var newWin=null;
    function openLookupPopup(name, id)
    {
        var url="/apex/YourcustomLookuppage?namefield=" + name + "&idfield=" + id;
        newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
        if (window.focus) 
        {
            newWin.focus();
        }
            
        return false;
    }  
</script>                  
  <apex:form >
    <apex:pageBlock title="Lookup">
      <apex:pageBlockSection columns="1">
        <apex:pageBlockSectionitem >
          <apex:outputLabel value="Account"/>
          <apex:outputPanel >
            <apex:inputHidden id="targetId" />
            <apex:inputText size="40"  id="targetName" onFocus="this.blur()" disabled="false"/>
            <img src="/s.gif" onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); return false" class="lookupIcon" onmouseout="this.className='lookupIcon';" alt="Account Name Lookup (New Window)" onmouseover="this.className='lookupIconOn';"/>           
          </apex:outputPanel>
        </apex:pageBlockSectionitem>
      </apex:pageBlockSection>
    
    </apex:pageBlock>
  </apex:form>  
 
</apex:page>

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
My Blog:- http://mrjavascript.blogspot.in/

 

Phillip SouthernPhillip Southern

Is the page against a data model/object in salesforce?  If so you could utilize the apex:inputfield component.

 

ex:

<apex:page standardcontroller="Account">

<apex:form>

<apex:pageblock>

<apex:pageblocksection>

<apex:pageblocksectionitem>

     <apex:inputfield value="{!Account.LOOKUPFIELD}"/>

</apex:form>

</apex:pageblock>

</apex:pageblocksection>

</apex:pageblocksectionitem>

</apex:page>

dieffreidieffrei
Use this component <c:AdvancedLookup> a custom visualforce component
 
<c:AdvancedLookup  sObjectName="Contract"  value="{!contractValue}"  searchFields="ContractNumber, AccountId, Status, StartDate, EndDate, ContractTerm" formFields="AccountId, Status, StartDate, EndDate, ContractTerm"  canCreate="true"  fieldLabel="ContractNumber"  onchange="onChangeContractHandler"/>



Github: https://github.com/dieffrei/visualforce-custom-lookup
Demo: https://dieffrei-com-developer-edition.na35.force.com

I hope you enjoy
dieffreidieffrei
Use this component <c:AdvancedLookup> a custom visualforce component
 
<c:AdvancedLookup  sObjectName="Contract"  value="{!contractValue}"  searchFields="ContractNumber, AccountId, Status, StartDate, EndDate, ContractTerm" formFields="AccountId, Status, StartDate, EndDate, ContractTerm"  canCreate="true"  fieldLabel="ContractNumber"  onchange="onChangeContractHandler"/>



Github: https://github.com/dieffrei/visualforce-custom-lookup
Demo: https://dieffrei-com-developer-edition.na35.force.com

I hope you enjoy