You need to sign in to do that
Don't have an account?
EliH
Visualforce extension not returning expected results
The goal is to display contracts related to an opportunity's account or its parent account on an opportunity page layout. The extension, however, is not returning any results to the visualforce page when it should.
Here is the visualforce code:
And here is my extension class:
Here is the visualforce code:
<apex:page standardController="Opportunity" extensions="RelatedContracts" tabStyle="Opportunity"> <apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!contracts}" var="c"> <apex:column value="{!c.AccountId}" /> <apex:column headerValue="ContractName"> <apex:outputLink value="{!URLFOR('/')}{!c.Id}" target="_blank">{!c.ContractNumber} </apex:outputLink> </apex:column> <apex:column value="{!c.Status}" /> <apex:column value="{!c.StartDate}" /> <apex:column value="{!c.Enddate}" /> <apex:column value="{!c.SpecialTerms}" /> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
And here is my extension class:
public with sharing class RelatedContracts { public Opportunity opp {get;set;} public Opportunity oppInfo {get;set;} public Account acct {get;set;} public List<Contract> contracts {get;set;} public RelatedContracts(ApexPages.StandardController controller){ opp = (Opportunity)controller.getRecord(); } public List<Contract> getcontracts(){ oppInfo = [SELECT AccountId from Opportunity WHERE id =: opp.Id]; acct = [SELECT Id, ParentId from Account WHERE id =: oppInfo.AccountId]; contracts = new List<Contract>(); contracts = [SELECT Id, RecordTypeId, Status, ContractNumber, StartDate, EndDate, SpecialTerms, Description FROM Contract WHERE AccountId =:oppInfo.AccountId or AccountId =:acct.ParentId]; System.debug('ContractList' + contracts); return contracts; } }
EliH
Sorry, I figured this out shortly after I posted it. In case anyone wants to see the resulting code: