+ Start a Discussion
Salesforce WizardSalesforce Wizard 

Dynamic Binding with Field Set within List causes error with no details

Ok so here's the scenario.


I have a map that contains a list of field names. On the page I'm iterating through the map and for each item in the map I iterate over the list of field names.


When I attempt to get the outputfield using dynamic binding I get an error -- but no error message.


If I pull out one of the lists in the extension and iterate through that list it works fine. It only errors when I attempt to display the information within a nested item.


Here's a slimmed down version of (example test) of what's in the controller


map<string,list<string>> mFields = new map<string,list<string>>();
list<string> templist = new list<string>();
for(Schema.FieldSetMember fm : Sobject.Case.FieldSets.TestSet.getFields()){


templist  = new list<string>();
templist.add('Subject'); templist.add('ContactID');



And then the page: I can't even save this because it doesn't like the Case[f]. It'll accept {!f} but nothing that'll let me reference the field. and I do a soql query for the fields in the controller, it's just not in the sample above.


<apex:pageblock title="tests">
   <apex:repeat value="{!mfields}" var="c">
      <apex:pageblocksection columns="2">
           <apex:repeat value="{!mFields[c]}" var="f">
              <apex:outputfield value="{!Case[f]}" />

 Now if I remove the first repeat and replace the value of the second repeat with say TempList (after making it available) it works great... It's only when I'm pulling it through the map.




What is the controller specified in the page definition?  Is this set controller or standard or ....


The reference case[f] looks suspicious to me.   You are going to need some controller method that returns the specific Case object whose field [f] you are going to display. 



Salesforce WizardSalesforce Wizard

Thanks for the reply!


I'm using the standardController="Case" with an extension as my class.


I've gotten the case[f] working if I just use the list of strings (not the nested one).


I've also tried having a method that queried all the needed fields for the case record (MyCase) and tried {!MyCase[f]} which provided me the same error with no actual error message. 


Similar to the case[f] version it works if I don't use the nested list of strings.


Interesting.  Seems like it ought to work if Case is valid.    I'll play with it a bit.

Salesforce WizardSalesforce Wizard

Okay, I've done some more testting and here's what I've found.


It has something to do specifically with the list being nestled. In this scenario I'm nestling a list of field names (from a field set) within a map (key's are string).



So here's my example:


here's a snippet of the controller. I have two vairables i'm going to call on my VF page. LFSM is a list of strings containing fields from the fieldset. mLtest is a map of a list of strings containing fields from a field set.


So in this method I'm simply building out the list of fields and either putting them in LFSM or mLTest.

    public list<string> lFSM {get;set;}
    public map<string,list<string>> mLtest {get;set;}
    public void TestData(){
       mlTest = new map<string,list<string>>();
       Schema.FieldSet FS = Schema.SobjectType.Case.fieldSets.getMap().get('TestSetting');
       list<Schema.FieldSet> lFs = new list<Schema.Fieldset>();
       lFSM = new list<string>();
       list<string> tempstrings = new list<string>();
       for(Schema.FieldSetMember f : fs.getfields()){
       system.debug('TEST FSM to String compare: ' + lfsm[0] + ' string: ' + test[0]); 
       FS = Schema.SobjectType.Case.fieldSets.getMap().get('ResearchRequest_Standard'); 
       for(Schema.FieldSetMember f : fs.getfields()){
       mlTest.put('Standard', tempstrings);
       system.debug('RIGHT BEFORE MAP TEST');
       system.debug('TEST Map string to FSM string: ' + mltest.get('Testsetting')[0] + ' FSM string: ' + lFSM[0]);     


And on the page the list<string> (LFSM) but when I iterate through the map i get a red ! with no error message... but


so this works:

           <apex:pageBlockSection title="LFSM Test">
               <apex:repeat value="{!lFSM}" var="t">
                   <apex:outputfield value="{!pCase[t]}" />


This gives me the error:


           <apex:repeat value="{!MlTest}" var="c">
               <apex:pageBlockSection title="{!c}">
                   <apex:repeat value="{!mltest[c]}" var="t">
                       <apex:outputfield value="{!pCase[t]}" /> <!--{!t} -->

 And this removes the error with no message, but only displays the name of the field:

           <apex:repeat value="{!MlTest}" var="c">
               <apex:pageBlockSection title="{!c}">
                   <apex:repeat value="{!mltest[c]}" var="t">


Looking at a debug log I see something interesting comparing the value from the Map list vs just a list. I don't know if that would impact it:


12:12:10:130 USER_DEBUG [59]|DEBUG|TEST Map string to FSM string: (Physician_List_Format__c) FSM string: Physician_List_Format__c


You can see that the value from the list that's nestled in the map outputs with (), but the value from the plain list doesn't.




I am having exactly same issue.   Any news or workarounds?