+ Start a Discussion
sfAdmin BanjosfAdmin Banjo 

Invalid field for Sobject for dynamic list of fields in Repeat tags

Hello, I got what must be a simple issue but for which I cannot get a solution : 
I have a custom object for which I am loading a list of records in a VF page. I get the list of fields from a Conga Query string by parsing the field names and building a list of field names, I then reference this list in a repeat component inside a pageblocktable but I get the following Error:

Exception: Invalid field Effective_Date__c for SObject loan__Repayment_Schedule__c 

The VF page code is:
<apex:pageblocksection title="repayment Schedule" columns="1">
            <apex:pageBlockTable value="{!schedule}" var="sched">
                <apex:repeat value="{!schedFields}" var="fld">
                    <apex:column value="{!sched[fld]}"/>

And the controller code is the following:
public with sharing class LoanAgreementConfigController {
    private loan__loan_account__c loan;
    private String schedQuery;
    public String[] schedFields {get;set;}

    public loan__Repayment_Schedule__c [] schedule {
            if(schedule == null)
                schedule = getRepaymentSchedule();
            return schedule;
        private set;
    public LoanAgreementConfigController(ApexPages.StandardController controller) {
         this.loan = (loan__loan_account__c)controller.getRecord();
         schedFields = new String []{};
    private loan__Repayment_Schedule__c[] getRepaymentSchedule() {
        return database.query(schedQuery);

    //this method queries the Conga Query table to get all query strings used in the Send Loan Agreement button, this will allow 
    //the query to be updated via Conga without disrupting this page.
    private void getAllCongaQueryStrings(){
        try {
            map<string,APXTConga4__Conga_Merge_Query__c> congaQueriesMap = new map<string,APXTConga4__Conga_Merge_Query__c> ();

            for(APXTConga4__Conga_Merge_Query__c congaquery: [Select id, APXTConga4__Name__c, APXTConga4__Query__c From APXTConga4__Conga_Merge_Query__c]){
                String recName = congaquery.APXTConga4__Name__c;
                String queryStr = congaquery.APXTConga4__Query__c.substringBefore('WHERE');
                if(recName == 'AmortizationSchedule'){
                    schedQuery = queryStr + 'WHERE loan__Loan_Account__c =\'' + loan.id + '\' ORDER BY loan__Due_Date__c ASC';
                    congaQueriesMap.put(recName, congaquery);
                    schedFields = congaquery.APXTConga4__Query__c.substringBefore('FROM').removeStart('SELECT').split(',');
        }catch (Exception e) {

Please mind the missing code as this is a bare bones page as I just started it, so no exception handling yet. Hopeful;ly someone can shed a light into what im missing here!!!