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
Uttam SaiRajUttam SaiRaj 

Custom Lookup in Visualforce Page

Hi, 

I have a requirement like i have to show a contact lookup in Visualforce page where am not using any standard controller  and when we are into the lookup i have to select the phone number in contact which i need it to send smsUser-added image
Can any 1 suggest me aregarding this.
Thanks in advance,
Sai
Best Answer chosen by Uttam SaiRaj
Uttam SaiRajUttam SaiRaj
Thanks for the Reply, am done with the requirement

VF Page :
  1.  <apex:inputField id="Account" value="{!con.Customer__c}">
  2.     <apex:actionSupport event="onchange" action="{!phn}"/>
  3.     </apex:inputField>
  4.     <apex:outputText value="{!Phone}"/>

Controller:
  1. public PageReference phn() {
  2.         //Id agmtId = String.valueOf(contact.get('contact__c'));
  3.         system.debug(con.Customer__c);
  4.         id ids = con.Customer__c;
  5.         contact ss = [select id,name,Phone from contact where id =: ids];
  6.         Phone = ss.Phone;
  7.         system.debug(ss);
  8.         return null;
  9.     }
This is what i have done, hope it will be useful for others.

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

Refer below link where you have sample code for the same.

https://developer.salesforce.com/forums/?id=906F000000094YKIAY
 
<apex:page controller="objectList">
   <apex:form >
  <apex:pageBlock mode="detail">
<!-- this is dummy lookup field on vf page-->
   <apex:inputField value="{!acc.ownerid}" />

<!-- passing lookup field value i.e userdid into controller methos  on button click-->
   <apex:commandButton action="{!searchdata}" title="search" value="search"/>


   </apex:pageblock>       
  </apex:form>                       
</apex:page>
 
controller :

public class objectList{

 

// creating dummy apex property
public Account acc {get;set;}

 

 // creating dummy method

   public String getAccount() {
        return null;
    }

public pagereference searchdata()
{

//you can fetch dummy lookup field vale here and process accordingly.
 System.debug('@@@@@@@@@@@'+acc.ownerid);
 return null;
}
 
  public objectList()
  {

 // instantiate your dummy object

    acc = new Account();
  }

Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
 
Best Regards
Sandhya
 
Uttam SaiRajUttam SaiRaj
Thanks for the Reply, am done with the requirement

VF Page :
  1.  <apex:inputField id="Account" value="{!con.Customer__c}">
  2.     <apex:actionSupport event="onchange" action="{!phn}"/>
  3.     </apex:inputField>
  4.     <apex:outputText value="{!Phone}"/>

Controller:
  1. public PageReference phn() {
  2.         //Id agmtId = String.valueOf(contact.get('contact__c'));
  3.         system.debug(con.Customer__c);
  4.         id ids = con.Customer__c;
  5.         contact ss = [select id,name,Phone from contact where id =: ids];
  6.         Phone = ss.Phone;
  7.         system.debug(ss);
  8.         return null;
  9.     }
This is what i have done, hope it will be useful for others.
This was selected as the best answer