You need to sign in to do that
Don't have an account?
prati@salesforce
Displaying all child records related to a parent on the child detail page
Hello everybody,
I am trying to display all child records related to a parent account, but I want to display it on the child visualforce page, not on the parent's. Site Visit1 is the child and Account is the parent Object.
Currently I am hard coding the account Id in my controller. But I would like to be able to somehow populate accountId here automatically.
When someone is on a siteVisit page, should see all the child of the same Account of which current site visit is a child of. Lets say We are looking at siteVisit A which has Account B, I wanted to show all the other children of Account B on the siteVisit A page. (I thought can be done by vf page) but cant figure out how to bind the id of account here. BTW doctor_office is the master field (Account) on the site visit object.Below is my code:
Controller extension
public class extendSiteVisit { public List<Site_Visit1__c> sites{get; set;} public extendSiteVisit(ApexPages.StandardSetController controller) { sites = [select id, Time_and_Date__c, name, AccountId__c from site_visit1__c where doctor_office__r.Id='0013600000EWmkB']; } }
Vf page
<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>
I am trying to display all child records related to a parent account, but I want to display it on the child visualforce page, not on the parent's. Site Visit1 is the child and Account is the parent Object.
Currently I am hard coding the account Id in my controller. But I would like to be able to somehow populate accountId here automatically.
When someone is on a siteVisit page, should see all the child of the same Account of which current site visit is a child of. Lets say We are looking at siteVisit A which has Account B, I wanted to show all the other children of Account B on the siteVisit A page. (I thought can be done by vf page) but cant figure out how to bind the id of account here. BTW doctor_office is the master field (Account) on the site visit object.Below is my code:
Controller extension
public class extendSiteVisit { public List<Site_Visit1__c> sites{get; set;} public extendSiteVisit(ApexPages.StandardSetController controller) { sites = [select id, Time_and_Date__c, name, AccountId__c from site_visit1__c where doctor_office__r.Id='0013600000EWmkB']; } }
Vf page
<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>
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
All Answers
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