------------------------------Apex Class---------------------------- public with sharing class AccContact {
public list<contact> conlst { get; set; } public list<account> accconts1 { get; set; }
public PageReference selacc() { string getid=apexpages.currentpage().getparameters().get('conlst'); accconts1=[select id,name, (select name from Opportunities ) from account where id=:getid ]; system.debug(accconts1); return null; }
public List<Account> acclst { get; set; } public AccContact (){ acclst=[select id,name from account ]; system.debug(acclst);
} }
Click the Account name on vf page and you will get a related opportunity. I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
------------------------------Apex Class---------------------------- public with sharing class AccContact {
public list<contact> conlst { get; set; } public list<account> accconts1 { get; set; }
public PageReference selacc() { string getid=apexpages.currentpage().getparameters().get('conlst'); accconts1=[select id,name, (select name from Opportunities ) from account where id=:getid ]; system.debug(accconts1); return null; }
public List<Account> acclst { get; set; } public AccContact (){ acclst=[select id,name from account ]; system.debug(acclst);
} }
Click the Account name on vf page and you will get a related opportunity. I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Here is apex code and VF page. Please use the below code:
---------------------------VF page-----------------------------
<apex:page controller="AccContact">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!acclst}" var="a">
<apex:column headerValue="Name">
<apex:commandLink action="{!selacc}">
<apex:param name="conlst" value="{!a.id}"/>
<apex:outputText value="{!a.name}"/>
</apex:commandlink>
</apex:column>
<!--accounts-->
</apex:pageBlockTable>
<apex:pageBlockTable value="{!accconts1}" var="a">
<apex:column headerValue="AccountName" value="{!a.Name}"/>
<!--contacts-->
<!--opportunities-->
<apex:column headerValue="Opportunity list">
<apex:pageBlockTable value="{!a.opportunities}" var="p">
<apex:column headerValue="Opportunity Name">
<apex:outputText value="{!p.name}">
</apex:outputText>
</apex:column>
</apex:pageBlockTable><!-- End opportunity-->
</apex:column>
</apex:pageBlockTable><!--end account-->
</apex:pageBlock>
</apex:form>
</apex:page>
------------------------------Apex Class----------------------------
public with sharing class AccContact {
public list<contact> conlst { get; set; }
public list<account> accconts1 { get; set; }
public PageReference selacc() {
string getid=apexpages.currentpage().getparameters().get('conlst');
accconts1=[select id,name, (select name from Opportunities ) from account where id=:getid ];
system.debug(accconts1);
return null;
}
public List<Account> acclst { get; set; }
public AccContact (){
acclst=[select id,name from account ];
system.debug(acclst);
}
}
Click the Account name on vf page and you will get a related opportunity.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Sachin Arora
www.sachinsf.com
All Answers
Please follow below code and remove contact details .
let me know incase any issue .
https://developer.salesforce.com/forums/?id=906F0000000g0WzIAI
Thanks ,
Manoj
Here is apex code and VF page. Please use the below code:
---------------------------VF page-----------------------------
<apex:page controller="AccContact">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!acclst}" var="a">
<apex:column headerValue="Name">
<apex:commandLink action="{!selacc}">
<apex:param name="conlst" value="{!a.id}"/>
<apex:outputText value="{!a.name}"/>
</apex:commandlink>
</apex:column>
<!--accounts-->
</apex:pageBlockTable>
<apex:pageBlockTable value="{!accconts1}" var="a">
<apex:column headerValue="AccountName" value="{!a.Name}"/>
<!--contacts-->
<!--opportunities-->
<apex:column headerValue="Opportunity list">
<apex:pageBlockTable value="{!a.opportunities}" var="p">
<apex:column headerValue="Opportunity Name">
<apex:outputText value="{!p.name}">
</apex:outputText>
</apex:column>
</apex:pageBlockTable><!-- End opportunity-->
</apex:column>
</apex:pageBlockTable><!--end account-->
</apex:pageBlock>
</apex:form>
</apex:page>
------------------------------Apex Class----------------------------
public with sharing class AccContact {
public list<contact> conlst { get; set; }
public list<account> accconts1 { get; set; }
public PageReference selacc() {
string getid=apexpages.currentpage().getparameters().get('conlst');
accconts1=[select id,name, (select name from Opportunities ) from account where id=:getid ];
system.debug(accconts1);
return null;
}
public List<Account> acclst { get; set; }
public AccContact (){
acclst=[select id,name from account ];
system.debug(acclst);
}
}
Click the Account name on vf page and you will get a related opportunity.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Sachin Arora
www.sachinsf.com