Hi prati, I have tried the same thing with below code :-
with the above code , current reocrd will return current site record detail with referance to current site detail you can get accoutId (parrentId) for that you can query all site related to that Account.Please let me know if you need any help on this,Thanks,Keyur Modi<apex:page standardController="Site_Visit1__c" extensions="extendSiteVisit" recordSetVar="sites">
<apex:pageBlock >
<apex:pageBlockTable var="s" value="{!sites}">
<apex:column headerValue="Name of Visit" >
<apex:outputField value="{! s.Name}"/>
</apex:column>
<apex:column headerValue="Date of Visit">
<apex:outputField value="{! s.Time_and_Date__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
public class extendSiteVisit {
public List<Site_Visit1__c> sites{get; set;}
public Opportunity Site_Visit1__c{get; set;}
public extendSiteVisit(ApexPages.StandardSetController controller) {
currentRecord = [SELECT Id, Name, AccoutID FROM site_visit1__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; // this will return current record object(child) detail from that you can use parent Id (here Account is parent so accoutId)
sites = [SELECT id, Time_and_Date__c, name, AccountId FROM site_visit1__c WHERE AccountId=:currentRecord.accountId];
}
}
답변 4개