Visualforce Error Help for this Page

System.NullPointerException: Attempt to de-reference a null object Error is in expression '{!Submit}' in component in page vfp_updateaddress_policyparty_peracc: Class.UpdateAddress_PolicyParty_PerAcc.Submit: line 99, column 1

Class.UpdateAddress_PolicyParty_PerAcc.Submit: line 99, column 1

Code snippet which is throwing error:

Public List<Account> AccUpdate{get;set;}
 List<Account> Acc_Uplst = [select id,PersonContactId from Account where PersonContactId = :PersnId]; 
 for(Account acc : Acc_Uplst){
                acc.Pending_Mailing_City__c = City;
                acc.Pending_Mailing_State__c = State;
                acc.Pending_Mailing_Street__c = Street;
                acc.Pending_Mailing_Zip_Code__c = Decimal.ValueOf(PostalCode);

                Update AccUpdate;

I'm assuming the error is AccUpdate.add(acc);, this would happen because you've not yet initialized that variable. Make sure you add this line before your for loop starts:

AccUpdate = new Account[0];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.