• Chris Morrison 7
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Working on a page with a repeat section that pulls in Opportunities related to an Account (standard controller). Inside the repeat I need to show the Contact Roles for each given Opportunity listed. So far I am not finding a way to do this. See related VF and extension controller. I am sure this is super simple but I can't figure it out for the life of me. 

Apex:
public class BlueSheetExtension {
    
    public List <Opportunity> WonOpty {get; set;}
    public List <Opportunity> OpenOpty {get; set;}
    public List <Contact> contacts {get; set;}
    public List <OpportunityContactRole> wonOptyRoles {get; set;}
    public List <OpportunityContactRole> openOptyRole {get; set;}
    public String prodlist {get; set;}
    
    
    public BlueSheetExtension(ApexPages.StandardController controller) {
        
        wonOpty = [Select Id, Name, Amount, Owner.Name, StageName, Last_Touch_Date__c, CloseDate, Goal__c, Actions_For_Goal__c, 
                Status_of_Action__c, red_flags__c, risks__c, terms_months__c, auto_renew__c, Auto_Renew_Months__c From Opportunity 
                Where IsWon = TRUE AND AccountId= :ApexPages.currentPage().getParameters().get('id')];
        
       OpenOpty = [Select Id, Name, Amount, Owner.Name, StageName, Last_Touch_Date__c, CloseDate, Goal__c, Actions_For_Goal__c, 
                Status_of_Action__c, red_flags__c, risks__c, terms_months__c, auto_renew__c, Auto_Renew_Months__c From Opportunity 
                Where IsClosed = FALSE AND AccountId= :ApexPages.currentPage().getParameters().get('id')];
           
        
        Contacts = [Select Id, Name, Title, Owner.Name, Buyer_Type__c, Mode__c, Meeting_Frequency__c 
               From Contact Where AccountId = :ApexPages.currentPage().getParameters().get('id')];
        
        wonOptyRoles = [Select Id, OpportunityId, Opportunity.Name, Contact.Name, Contact.Title, Contact.Owner.Name, Contact.Buyer_Type__c, Contact.Mode__C, Contact.Meeting_Frequency__c 
                From OpportunityContactRole where OpportunityId IN 
                (Select Id from Opportunity Where IsWon = TRUE AND AccountId= :ApexPages.currentPage().getParameters().get('id') )];
        
        openOptyRole = [Select Id, OpportunityId, Opportunity.Name, Contact.Name, Contact.Title, Contact.Owner.Name, Contact.Buyer_Type__c, Contact.Mode__C, Contact.Meeting_Frequency__c 
                From OpportunityContactRole where OpportunityId IN 
                (Select Id from Opportunity Where IsClosed = FALSE AND AccountId= :ApexPages.currentPage().getParameters().get('id') )];
    }

}



VF markup:
<apex:page lightningStylesheets="true" standardController="Account" extensions="BlueSheetExtension">
  <div style="text-align: center;"><img src="{!$Resource.EnveraLogo}"/>
    </div>
   <div style="text-align: center; font-size: 150%;">
        Blue Sheet for {!Account.Name}
    </div>
    <apex:sectionHeader title="Section I. Account Summary"/> <!--Basic Account information-->
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:outputField value="{!Account.Name}" label="Account Name:"/>
            <apex:outputField value="{!Account.Owner.Name}" label="Account Owner:"/>         
        </apex:pageBlockSection>
        <apex:pageBlockSection >
            <apex:outputField value="{!Account.Account_Summary__c}" label="Account Summary:"/>       
        </apex:pageBlockSection>
    </apex:pageBlock>  
    	<apex:sectionHeader title="Section II. Current Services"/> <!--Data for this section comes from Closed Won Opportunities only-->
    	<apex:repeat value="{!WonOpty}" var="w">
    		<apex:pageBlock >      
        	<apex:pageBlockSection >
            	<apex:outputField value="{!w.Name}" label="Opportunity Name:"/>
                <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
            	<apex:outputField value="{!Account.Name}" label="Product:"/>
            	<apex:outputField value="{!w.Amount}" label="Amount:"/>
            	<apex:outputField value="{!w.Owner.Name}" label="Opportunity Owner:"/>
            	<apex:outputField value="{!w.StageName}" label="Stage:"/>
            	<apex:outputField value="{!w.Last_Touch_Date__c}" label="Last Touch Date:"/>
            	<apex:outputField value="{!w.CloseDate}" label="Close Date:"/>
            	<apex:outputField value="{!w.terms_months__c}" label="Terms Months:"/>
            	<apex:outputField value="{!w.Auto_Renew__c}" label="Auto Renew:"/>
            	<apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
            	<apex:outputField value="{!w.Auto_Renew_Months__c}" label="Auto Renew Months:"/>
                <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
            	<apex:outputField value="{!w.Goal__c}" label="Goal:"/>
            	<apex:outputField value="{!w.Actions_For_Goal__c}" label="Actions for Goal:"/>
            	<apex:outputField value="{!w.Status_of_Action__c}" label="Status for Action"/>
            	<apex:pageBlockSectionItem ></apex:pageBlockSectionItem>
            	<apex:outputField value="{!w.Red_Flags__c}" label="Red Flags"/>
            	<apex:outputField value="{!w.Risks__c}" label="Risks"/>
            	</apex:pageBlockSection>
            <apex:pageBlockSection columns="1" title="Buying Influence" ><!--Contact Roles for the related Opportunity -->  
            <!--Data Table used because of repeating section data shenanigans. I don't like it either and I am sure there is a better way-->  
            <apex:dataTable title="Buyer Influence" value="{!WonOptyRoles}" var="wor"  rules="rows" style="border-color: #f3f2f2">    
       		 <apex:column >
            	<apex:facet name="header">Name</apex:facet>
            	<apex:outputText value="{!wor.contact.name}" style="display: {!IF(w.id=wor.OpportunityId,'table-row','none')}"/>
       		 </apex:column>
        	<apex:column >
            	<apex:facet name="header">Title</apex:facet>
            	<apex:outputText value="{!wor.contact.title}" style="display: {!IF(w.id=wor.OpportunityId,'table-row','none')}"/>
        	</apex:column>
                <apex:column >
            	<apex:facet name="header">Contact Owner</apex:facet>
            	<apex:outputText value="{!wor.contact.owner.name}" style="display: {!IF(w.id=wor.OpportunityId,'table-row','none')}"/>
        	</apex:column>
                <apex:column >
            	<apex:facet name="header">Buyer Type</apex:facet>
            	<apex:outputText value="{!wor.contact.Buyer_Type__c}" style="display: {!IF(w.id=wor.OpportunityId,'table-row','none')}"/>
        	</apex:column>
                <apex:column >
            	<apex:facet name="header">Mode</apex:facet>
            	<apex:outputText value="{!wor.contact.Mode__c}" style="display: {!IF(w.id=wor.OpportunityId,'table-row','none')}"/>
        	</apex:column>
                <apex:column >
            	<apex:facet name="header">Meeting Frequency</apex:facet>
            	<apex:outputText value="{!wor.contact.Meeting_Frequency__c}" style="display: {!IF(w.id=wor.OpportunityId,'table-row','none')}"/>
        	</apex:column>
            </apex:dataTable>
            </apex:pageBlockSection>
            </apex:pageBlock>
    	</apex:repeat>
I am new to development and working on a VF page that will show data from Opportunity, Account and Contact Roles. The standard controller is Opportunity and have tried to build an extension to bring in the parent Account data I need. I started with a list controller and can't get the data to display in an Apex:Output field tag. I get an error that says" Unknown property 'VisualforceArrayList.Account'". It does work when using an apex:PageBlockTable and setting the value of the table to the variable. I don't need or want a table I just want an Output. Here is my controller syntax:
public class DealReviewSheetContactRoleExtension{
    public list<Opportunity> Acco{
        get;
        set;
    }
    public DealReviewSheetContactRoleExtension(
    	ApexPages.StandardController controller
    ){
        Acco = 
            [SELECT
            	Account.Name,
            	Account.AnnualRevenue,
             	Account.BillingAddress
        
            FROM
            	Opportunity
            WHERE
            	Id =
            	:((Opportunity)controller.getRecord()).Id
            ];
    }
}
and here is the relevent block on the VF page:
<apex:pageBlock >
            <apex:pageBlockSection >

                <apex:outputField value="{!Opportunity.Name}" label="Point Person:"/>
                <apex:outputField value="{!Acco.Account.AnnualRevenue}" label="Annual Revenue"/>
Any guidance would be greatly appreciated!

 
I am new to development and working on a VF page that will show data from Opportunity, Account and Contact Roles. The standard controller is Opportunity and have tried to build an extension to bring in the parent Account data I need. I started with a list controller and can't get the data to display in an Apex:Output field tag. I get an error that says" Unknown property 'VisualforceArrayList.Account'". It does work when using an apex:PageBlockTable and setting the value of the table to the variable. I don't need or want a table I just want an Output. Here is my controller syntax:
public class DealReviewSheetContactRoleExtension{
    public list<Opportunity> Acco{
        get;
        set;
    }
    public DealReviewSheetContactRoleExtension(
    	ApexPages.StandardController controller
    ){
        Acco = 
            [SELECT
            	Account.Name,
            	Account.AnnualRevenue,
             	Account.BillingAddress
        
            FROM
            	Opportunity
            WHERE
            	Id =
            	:((Opportunity)controller.getRecord()).Id
            ];
    }
}
and here is the relevent block on the VF page:
<apex:pageBlock >
            <apex:pageBlockSection >

                <apex:outputField value="{!Opportunity.Name}" label="Point Person:"/>
                <apex:outputField value="{!Acco.Account.AnnualRevenue}" label="Annual Revenue"/>
Any guidance would be greatly appreciated!