0

I am having an issue where the query results are not displaying in my vf page. I've gone as far as temporarily assigning a specific id so that I know that I get a return value from my query. I don't understand why nothing is displayed on the page.

Controller:

public class ReviewAccountCovenants {

public String currentRecordID= '001j000000VgiQN';
public LLC_BI__Review__c Review                 {get;set;}
public Loan_Memo__c myMemo                      {get;set;}
public list<LLC_BI__Covenant2__c> relatedcovs   {get;set;}
public void GatherCovenants(){   
    list<LLC_BI__Covenant2__c> relatedcovs =  [
    SELECT Id, Requirement__c, Actual__c, LLC_BI__Covenant_Type__c, Name 
    FROM LLC_BI__Covenant2__c
    WHERE Id in (
            SELECT LLC_BI__Covenant2__c
            FROM LLC_BI__Account_Covenant__c
            WHERE LLC_BI__Account__c  =: currentRecordID)]; 

    system.debug(relatedcovs);

    }
    }

VF Page

<apex:form >
    <div>
        <apex:pageBlock >
            <apex:pageBlockTable var="covenant" value="{!relatedcovs}"  >   
                <apex:column headerValue="Covenant Type">
                    <apex:outputField value="{!covenant.LLC_BI__Covenant_Type__c}" />
                </apex:column>
                <apex:column headerValue="Requirement">
                    <apex:inputField value="{!covenant.Requirement__c}" />
                </apex:column>      
                <apex:column headerValue="Actual">
                    <apex:inputField value="{!covenant.Actual__c}" />
                </apex:column>

            </apex:pageBlockTable>

        </apex:pageBlock>
    </div>
</apex:form>

1

You've put your query into a function that's never called. Instead, you can just change it to a constructor, and drop the local variables.

public class ReviewAccountCovenants {

    public String currentRecordID= '001j000000VgiQN';
    public LLC_BI__Review__c Review                 {get;set;}
    public Loan_Memo__c myMemo                      {get;set;}
    public list<LLC_BI__Covenant2__c> relatedcovs   {get;set;}
    public ReviewAccountCovenants(){   // Constructors have no return type
        // Use the class level member relatedcovs
        relatedcovs =  [SELECT Id, Requirement__c, Actual__c, LLC_BI__Covenant_Type__c, Name 
                        FROM LLC_BI__Covenant2__c
                        WHERE Id in (
                            SELECT LLC_BI__Covenant2__c
                            FROM LLC_BI__Account_Covenant__c
                            WHERE LLC_BI__Account__c  =: currentRecordID)]; 
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.