I already referred link : How to handle maps with no key match and unable to implement logic something simillar, because every time I am getting fields in a Map is dynamic.
I have a below logic
public Map<String,sObject> TInfoDetails {get; set;}
public Map<String,String> tFieldList;
.........
.........
........
public void gettInfo(){
if(tFieldList != null){
for(String objectName : tFieldList.keyset()){
String queryStr = 'SELECT Id,' + tFieldList.get(objectName)) + ' FROM '+objectName+' WHERE Case__c = ' + '\'' + currentCase.Id + '\'' LIMIT 1';
List<Sobject> value = Database.query(queryStr);
if(value != null && !value .isEmpty()){
TInfoDetails.put(objectName,value[0]);
}
}
}
}
It's always not necessary that this MAP will always populate, when I am iterating through that Map like below I see the "Transaction__c map key not found".
public map<Decimal, List<Transaction__c>> tFieldsConfigMap {get;set;}
public map<Decimal, Transaction__c> tSectionMap {get;set;}
public Map<String,sObject> tInfoDetails {get; set;}
<apex:repeat value="{!tFieldsConfigMap}" var="map1">
<apex:pageBlockSection title="{!IF( tSectionMap[map1].Section__c != 1, tSectionMap[map1].SectionLabel__c,'')}" columns="{!tSectionMap[map1].ColumnsPerSection__c}" rendered="{!tSectionMap[map1].SectionName__c != 'ABC'}">
<apex:repeat value="{!tFieldsConfigMap[map1]}" var="map2">
<apex:pageBlockSectionItem rendered="{!map2.Object__c != 'XXXX'}">
<apex:outputLabel value="{!map2.FieldLabel__c}"/>
<apex:outputField value="{!tInfoDetails[map2.Object__c][map2.FieldNameAPI__c]}"/>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:repeat>