I am getting the above error at below line. Can someone Please let me know? It should be true or false , why null?
Apex class
List<Account> Accnt= [select ID , Name , Restricted_Products_vod__c from Account where ID=:Test.Account_abv__c];
if(!Accnt.isEmpty()){
Restrict = Accnt[0].Restricted_Products_vod__c ;
}
List<Product_vod__c> prd= [select ID , Name from Product_vod__c where ID=:ProductID];
if(!prd.isEmpty()){
Prodrestrict= prd[0].Name;
}
if(Restrict.contains(Prodrestrict)) //This line throws error
{
ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Selected Product is restricted for selected Account.');
ApexPages.addMessage(Msg);
}
Restrict
is null. That's the only way you'd get that error. Try puttingSystem.assertNotEquals(null, Restrict);
on the line before to see if it fails. – sfdcfox Feb 19 '16 at 17:03if(!prd.isEmpty()){ Prodrestrict= prd[0].Name; if(Restrict.contains(Prodrestrict)) //This line throws error { ApexPages.Message Msg = new ApexPages.Message(ApexPages.Severity.FATAL, 'Selected Product is restricted for selected Account.'); ApexPages.addMessage(Msg); } }
– Ratan Paul Feb 19 '16 at 17:30