+ Start a Discussion

search function using loolup



i have obj named patient_receipt__c, it has lookup field for patient name, if i select the name and click search it should display the details ..but it is not working and i  don't knw where i did mistake..


my controller:


public class viewrec
public String temp;
Public Boolean show{set;get;}
public Patient_Receipt__c pr{get; set;}
Public  list<Patient_Receipt__c>prlst{set;  get;}

    public viewrec()
    pr= new Patient_Receipt__c();
    show= false;

    public pageReference fees()
    if(pr.Name__c!= null)

   //prlst= (list<Patient_Receipt__c>)[select Name__c,Registration_Number__c,Age__c,Diagnosis_Fees__c,E_C_G_Fees__c,Indoor_Injection_Fees__c,Lab_Fees__c,X_Ray_Fees__c,Total_Fee__c from Patient_Receipt__c WHERE Name like: temp];
   pr= [select Name__c,Registration_Number__c,Age__c,Diagnosis_Fees__c,E_C_G_Fees__c,Indoor_Injection_Fees__c,Lab_Fees__c,X_Ray_Fees__c,Total_Fee__c from Patient_Receipt__c WHERE Name =: temp];
    show= true;
    return null;  

    public pageReference clr()
    return null;



my page:



<apex:page controller="viewrec" >

<apex:form >

<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!pr.Name__c}" label="Patient name"/>

<apex:pageBlockButtons location="bottom">
<apex:commandButton value="view fee details" action="{!fees}"/>
<apex:commandButton value="Clear" action="{!clr}"/>

<apex:pageBlockTable rendered="{!show}" value="{!pr}" var="d">
<apex:column value="{!d.Name__c}" />
<apex:column value="{!d.Registration_Number__c}" />
<apex:column value="{!d.Age__c}" />
<apex:column value="{!d.Diagnosis_Fees__c}" />
<apex:column value="{!d.E_C_G_Fees__c}" />
<apex:column value="{!d.Indoor_Injection_Fees__c}" />
<apex:column value="{!d.Lab_Fees__c}" />
<apex:column value="{!d.X_Ray_Fees__c}" />
<apex:column value="{!d.Total_Fee__c }" />






hi ,

I think we can use trigger also for this 

i have a sample trigger

trigger tregistration on book__c(after insert) 

for(book__c b:trigger.new)
list<registration__c> rlist=[select bookname__c,bookid__c,authorname__C from registration__C where bookid__c=:b.bookid__c];
registration__c r=new registration__c();
update r;

It may useful to you..........



A lookup will populate an ID, not a name.  So if you then try to use that value in a SOQL query, you'll need to match on the id.