I have got a lot of research and recherche done as this simple where clause doesn't work because of it self-reference.
I want to display all leads and opportunities who have the same "datefield x" as the actually shown lead in a visual force standard list controller. Has anybody an idea how to solve this?
VF-Page
<apex:page controller="c2" extensions="extension_current_lead">
<apex:pageBlock title="Leads" >
<apex:PageBlockTable value="{!acts}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Budget__c}"/>
<apex:column value="{!a.Eventart__c}"/>
<apex:column value="{!a.Gaestezahl__c}"/>
</apex:PageBlockTable>
<apex:PageBlockTable value="{!acts2}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Amount}"/>
<apex:column value="{!a.EventArtC__c}"/>
<apex:column value="{!a.AnzahlDerGaeste_C__c}"/>
</apex:PageBlockTable>
apex class
public class c2{
List<Lead> currentLeads = [SELECT DatumEvent__c FROM Lead WHERE Id = :currentId];
if (!currentLeads.isEmpty()) {
Date currentDate = currentLeads[0].DatumEvent__c;
List<Lead> acts = [SELECT Id, Name, Budget__c, Eventart__c, Gaestezahl__c FROM Lead WHERE DatumEvent__c = :currentDate];
List<Opportunity> acts2 = [SELECT Name, Amount, EventArtC__c, AnzahlDerGaeste_C__c FROM Opportunity WHERE DatumEvent__c = :currentDate];
public List<Lead> getacts(){
return acts;
}
public List<Opportunity> getacts2(){
return acts2;
}
}
Error: Kompilierungsfehler: Expecting '}' but was: 'if' in Zeile 5, Spalte 1
Update: I created an extension class as suggested.
public class extension_current_lead
{
public Lead lead{get;set;}
public extension_current_lead ()
{
Id id=apexpages.curentPage().getParameters().get('ID');
kead=[select Id, Name, Budget__c, Eventart__c, Gaestezahl__c from Lead where ID=:id];
}
}