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
MrithulaMrithula 

How to render a field based on the lookup

hi ,

iam new to salesforce and iam facing with the following issue... can anyone help me ...

i have 3 objects..

1.patient_details -> here i collect patient name and doctor name(lookup) they want to meet.

 

2.patient _traking -> i want to create track sheet  that has details like patient name(lookup), bed no , ward no, doctor name  after entering this details i want to save this record.

 

iam facing the pblm when creatin the scenario...

 

when i choose the patient name in lookup , the doctor they consulted should be displayed automatically...i don't know how to bring this...

my code is here...

 

PAGE:

 

<apex:page controller="track" >
<apex:form >
<apex:pageBlock >

<apex:pageBlockSection title="Patient Tracking System" columns="2">

<apex:inputField value="{!pt.Name__c}"/>
<apex:outputPanel id="out">
<apex:outputtext value="{!pt.staff_details__c}"/>
</apex:outputPanel>
<apex:inputField value="{!pt.Type_of_treatment__c}"/>
<apex:inputField value="{!pt.Status__c}"/>
<apex:inputField value="{!pt.Priority__c}"/>
<apex:inputField value="{!pt.Bed_No__c}"/>

</apex:pageBlockSection>

<apex:pageBlockSection title="Search">
<apex:outputLink value="{!URLFOR('https://c.ap1.visual.force.com/apex/tracksearch')}">
Track the patient
</apex:outputLink>

</apex:pageBlockSection>

 

<apex:pageBlockButtons location="bottom">
<apex:commandButton value="SAVE" action="{!savenew}"/>
<apex:commandButton value="CANCEL" action="{!cancelnew}"/>
<apex:commandButton value="CLEAR" action="{!clr}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

CONTROLLER:

 

public class track
{
public Patient_tracking__c pt{set;get;}

public track()
{
pt= new Patient_tracking__c ();
Id ptId= ApexPages.currentPage().getParameters().get('ptId');

pt=(ptId==null)? new Patient_tracking__c ():

[select Name__c,Bed_No__c,Priority__c,staff_details__c,Status__c,Type_of_treatment__c from Patient_tracking__c where id=:ptId];

}
public pageReference savenew()
{
try
{
upsert pt;


ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Your data was saved successfully'));
}

catch(Exception e)
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
}


pageReference pg= new pageReference('/apex/trackview');
pg.getParameters().put('ptId',pt.id);
pg.setRedirect(true);
return pg;
}

public pageReference Edit()
{
pageReference pg= new pageReference('/apex/trackpatient');
pg.getParameters().put('ptId',pt.id);
pg.setRedirect(true);
return pg;
}

 

public pageReference clr()
{
pt= new Patient_tracking__c ();
return null;
}


public pageReference cancelnew()
{
pageReference pg = new pageReference ('https://ap1.salesforce.com/home/home.jsp');
pg.setRedirect(true);
return pg;
}


}

 

 

 

AravindBabu512AravindBabu512

Based on the data model of yours, I can see that a patient can have only one doctor. In that case you can pull the information from Doctor's name from the patient object as a formula field in your tracking object. You may not necessarily need a VF page is this is the only scenario for which you are going to a VF.

 

Thanks,

Aravind

MrithulaMrithula

hi,

 

i heard 'onchange' and ' action support' will be helpful...but i don't have any idea on that.