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
reddygari403reddygari403 

find this error .System.NullPointerException: Attempt to de-reference a null object

Hi everybody plz find the above error.the below program is for adding columns dynamicaly.plz find the error public class Demo { public map mapFieldToShow{get;set;} public map mapFieldToShow1{get;set;} list lstfield=new list(); list lstflabel=new list(); public Integer noOfColumns // User input { get; set { listFieldToShow = new List(); // listFieldToShow.addAll(lstField); for(integer i=0;i listFieldToShow {get;set;} List fieldLabels=new List(); public Demo() { Contactfields__c objp=[select objectName__c from Contactfields__c limit 1]; SObjectType objToken = Schema.getGlobalDescribe().get(objp.objectName__c); DescribeSObjectResult objDef = objToken.getDescribe(); Map fieldmap = objDef.fields.getMap(); for(Contactfields__c obj:[select fieldName__c from Contactfields__c order by Fieldvalue__c]) // query from custom settings. lstfield.add(obj.fieldName__c); listFieldToShow = new List(); mapFieldToShow = new Map(); mapFieldToShow1 = new Map(); for(integer i=0;i listTableResult { get;set; } public PageReference Add() { return ApexPages.currentpage(); } public List getlistTableResult() { return listTableResult; } public void setlistTableResult(List Contacts) { listTableResult = Contacts; } public PageReference save() { // to save updates. upsert listTableResult; return null; } } ============= {!mapFieldToShow1[colItem]}
sfdcfoxsfdcfox

It's hard to read your source code. Could you please re-post your question, and use the "Code" button in the toolbar (the clipboard with the "C" next to it, the sixth button from the left when editing a post). Your code should look like this:

 

public class Demo {
  public map ...

Your code is illegible, and doesn't even make sense as it is written now (it appears that the code would not compile).