You need to sign in to do that
Don't have an account?
kiran raju 19
Display the related contact in the opportunity
Hi all,
I want to display the contact in the Opportunity which are related to the same account in the salesforce lighting.
Can anyone help over here.
Thanks in advance,
raju.
I want to display the contact in the Opportunity which are related to the same account in the salesforce lighting.
Can anyone help over here.
Thanks in advance,
raju.
you can follow below code:-
if you fond this useful then, PLEASE MARK AS A BEST ANSWER!!
Regards
Mukesh
In order to do this, you can create an inline VF page and attach that page to the opportunity.
Here I have created a page that will display the Account,Contact and its related opportunities.
Please refer to the sample code
<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-->
<apex:column headerValue="list contacts">
<apex:pageBlockTable value="{!a.contacts}" var="c">
<apex:column headerValue="ContactName">
<apex:outputText value="{!c.lastname}"></apex:outputText>
</apex:column>
<!--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 contact-->
</apex:column>
</apex:pageBlockTable><!--end account-->
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public with sharing class AccContact {
public list<contact> conlst { get; set; }
// public contact c { get; set; }
/* public void getSelacc() {
}*/
public list<account> accconts1 { get; set; }
public PageReference selacc() {
string getid=apexpages.currentpage().getparameters().get('conlst');
accconts1=[select id,name,(select id,lastname from contacts) ,(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);
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha