You need to sign in to do that
Don't have an account?
Chirag_Joshi
Cannot retrieve value of map from List of Map in <apex:pageblocktable> columns except 'Name'
VF Page:
Apex Controller:
Error:
<apex:page controller="FLSController2"> <apex:form > <apex:pageBlock title="FLS Test" > <apex:inlineEditSupport event="onDblClick"/> <apex:pageMessages /> <apex:pageBlockTable value="{!acc}" var="a"> <apex:column headerValue="Account Name" value="{!a['Name']}" rendered="{!$ObjectType.Account.Fields.Name.Accessible}"/> <apex:column headerValue="Phone" value="{!a['Phone']}" rendered="{!$ObjectType.Account.Fields.Phone.Accessible}"/> <apex:column headerValue="Industry" value="{!a['Industry']}" rendered="{!$ObjectType.Account.Fields.Industry.Accessible}"/> <apex:column headerValue="Rating" value="{!a['Rating']}" rendered="{!$ObjectType.Account.Fields.Rating.Accessible}"/> <apex:column headerValue="Type" value="{!a['Type']}" rendered="{!$ObjectType.Account.Fields.Type.Accessible}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Apex Controller:
public with sharing class FLSController2 { public List<Map<String, String>> acc; public FLSController2(){ acc = new List<Map<String, String>>(); } public List<Map<String, String>> getacc(){ List<Account> aList = [SELECT Name, Industry, Phone, Rating, Type FROM Account]; for(Account a: aList){ Map<String, String> m = new Map<String, String>(); m.put('Name', a.Name); m.put('Industry', a.Industry); m.put('Phone', a.Phone); m.put('Rating', a.Rating); m.put('Type', a.Type); acc.add(m); } return acc; } }
Error:
Hello Chirag,
You are getting exception due to null values. Keep null check before putting the values in list.
Regards,
Srikath K
All Answers
Hello Chirag,
You are getting exception due to null values. Keep null check before putting the values in list.
Regards,
Srikath K
Updated VF Page:
Updated Apex Controller: