function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Christopher PezzaChristopher Pezza 

Error with Field Sets and Objects

So I'm building a configurable visualforce page that in an object you type the name of field sets and sech to then display a tabbed view but i get this error when i do so what am i missing 

Error: Could not resolve field '0IX' from <apex:outputField> value binding '{!LLC_BI__Loan__c[f]}' in page ncino_checklist

Apex Class
public with sharing class nCino_ChecklistExt{

    public ApexPages.StandardController stdCtrl {get; set;}
    public Boolean refreshPage {get; set;}
    List<nCino_Config__c> configvalues {get;set;}

        public nCino_ChecklistExt(ApexPages.StandardController controller) {
        stdCtrl=controller;
        refreshPage=true;
    }
    
    public List<nCino_Config__c> getConfigValues() {
    
        configvalues = [SELECT Id, Name, Tab_Name__c, Tab_Display_Order__c, Tab_Color__c, Tabbed_Content_Name__c, Icon_for_Tab__c, Field_Set__c 
                        FROM nCino_Config__c 
                        WHERE App_Name__c = 'Checklist' 
                        ORDER BY Tab_Display_Order__c DESC];
        
    return configvalues;
    }
    
    public PageReference save(){
        LLC_BI__Loan__c loan=(LLC_BI__Loan__c) stdCtrl.getRecord();
        stdCtrl.save();

      return null;
    }
    
    public PageReference cancel(){
        LLC_BI__Loan__c loan=(LLC_BI__Loan__c) stdCtrl.getRecord();  
        stdCtrl.save();  
      return null;
    }

}

Visualforce Page
<apex:page showHeader="false" sidebar="false" standardController="LLC_BI__Loan__c" extensions="nCino_ChecklistExt" standardStylesheets="true">

<head>
<apex:stylesheet value="{!URLFOR($Resource.bootstrap, '/css/bootstrap.css')}"/>
<style type="text/css">
.thebox{
    margin: 15px;
    width:auto;
    height:400px;
    background-color:#F0F0F0;
    border-radius:15px;
    }
    
.left-side{
    float:left;
    width:16.66666667%;
    background-color:#FFF;
    height:400px;
    }
    
.right-side{
    float:left;
    width:83.33333333%;
    height:400px;
    }

.border-green{border-left-color:#88C240;border-left-width:5px;}
.border-blue{border-left-color: #2D79D7;border-left-width:5px;}
.border-red{border-left-color: #BA202F;border-left-width:5px;}
.border-yellow{border-left-color: #F5AB3F;border-left-width:5px;}
.border-gray{border-left-color: #666;border-left-width:5px;}

.top-border-blue{border-top-color:#88C240;border-top-width:5px;}

</style>

<title>Untitled Document</title>
</head>
<div class="thebox">
    <div class="left-side">
        <div class="list-group" role="tablist" id="myTab">
            <apex:repeat value="{!ConfigValues}" var="cv">
                <a href="#tab{!cv.Tab_Display_Order__c}" class="list-group-item border-{!cv.Tab_Color__c}" role="tab" data-toggle="tab"><i class="gyphicon glyphicon-{!cv.Icon_for_Tab__c}"></i>&nbsp;{!cv.Tab_Name__c}</a>
            </apex:repeat>
        </div>
    </div>
    <apex:form>
    <div class="right-side tab-content" id="myTabcontent">
        <div class="tab-pane active">
            Main Page :)
        </div>
        <apex:repeat value="{!ConfigValues}" var="ncv">
            <div class="tab-pane" id="tab{!ncv.Tab_Display_Order__c}">
                <apex:pageBlock title="{!ncv.Tabbed_Content_Name__c}">
                    <apex:pageBlockSection>
                        <apex:variable value="{!ncv.Field_Set__c}" var="fieldset"/>
                        <apex:repeat value="{!$ObjectType.fieldset}" var="f">
                            <apex:outputField value="{!LLC_BI__Loan__c[f]}">
                                <apex:inlineEditSupport event="ondblclick"/>
                            </apex:outputField> 
                        </apex:repeat>  
                    </apex:pageBlockSection>     
                    <apex:pageBlockButtons location="bottom">
                        <apex:commandButton action="{!save}" value="Save"/>
                        <apex:commandButton action="{!cancel}" value="Cancel"/>
                    </apex:pageBlockButtons>                
                </apex:pageBlock>
            </div>
        </apex:repeat>
       
    </div>
    </apex:form>
</div>

<apex:includeScript value="{!URLFOR($Resource.bootstrap, '/js/jquery-2.1.1.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.bootstrap, '/js/bootstrap.min.js')}"/>

<script>
  $('#myTab a').click(function (e) {
  e.preventDefault()
  $(this).tab('show')
})
</script>
</apex:page>


ShashForceShashForce
The syntax {!LLC_BI__Loan__c[f]} doesn't seem correct. Could you please check again?
Christopher PezzaChristopher Pezza
It is the object is from an installed package so it has a name prefix on it as well so that is the full api name. I double checked and it still didn't like it. When i comment out line 58-60 the code works normal without displaying any fields but it runs.
ShashForceShashForce
Please try this syntax and check if it helps:

<apex:repeat value="{!$ObjectType.LLC_BI__Loan__c.fieldsets.properNames}" var="f">
                            <apex:outputField value="{!LLC_BI__Loan__c[f]}">
                                <apex:inlineEditSupport event="ondblclick"/>
                            </apex:outputField>

Reference: http://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_field_sets.htm
Christopher PezzaChristopher Pezza
the downside to that i want to make this dynamic so that it is done via an object to populate the tab and use of fieldsets.

the field called field_set_c in the code is what fills out with everything after ObjectType.
KevinPKevinP
Not sure I understand what you're trying to do? You want a VF page that lets you select which one of many fieldsets you want to display? Can you be a bit more detailed about the problem you're solving? 

As for the proximate problem: I believe the issue is stemming from $objectType not being able to resolve fieldset. Since Field_Set__C is, I'm assuming a text custom variable, you'll need to resolve your object tokens in Apex, before you can utilize the $objectType global variable. I believe what's happening, is that the $objectType call is trying to resolve a string represnetation of your object rather than an apex object token.

This page https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_id.htm includes example code for getting a sObject Token from an ID. You could utilize this to resolve this issue by ensuring that there's a mandatory lookup on your nCino config to the sObject that is being referenced by that given Fieldset. Once you have an id to the object owning the fieldset, you can use the code I linked above to get a token.