You need to sign in to do that
Don't have an account?
Brian Romanowski
dereference a null object but object is not null
I'm trying to create a list of related ID's to a custom object, Base Elements. I check if the value is null in the SOQL and put in a conditioonal statement checking it again but when I go to add it to the list I get the System.NullPointerException: Attempt to de-reference a null object. I underlined the add statement that is causing the error. Any idea what is going on?
FOR (BMCServiceDesk__BMC_BaseElement__c b : [SELECT BMCServiceDesk__PrimaryClient__c FROM BMCServiceDesk__BMC_BaseElement__c WHERE BMCServiceDesk__PrimaryClient__c!=null ]) { system.debug('pc: '+b.BMCServiceDesk__PrimaryClient__c); if(b.BMCServiceDesk__PrimaryClient__c!=null){ system.debug('this is not null!!'); bepc.add(b.BMCServiceDesk__PrimaryClient__c); } }
instead of:
All Answers
instead of:
I do not see any decleration for this list (bepc), are you sure you are instantiating this list properly.
Please do let me know if this is not the case.