• Apurve Srivastava
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
i am getting error "System.QueryException: List has no rows for assignment to SObject"  in 

List<Account> ac = [SELECT Id,Name,(SELECT LastName FROM Contacts) FROM Account WHERE Name = 'Acme'];
List<Contact> con = new List<Contact>();
for(Account a : ac){    
     System.debug(a.Contacts);
    if(a.Contacts == null){
        System.debug('null');
    }
    else{
        con.add(a.Contacts);
    }
}

 plz tell me how i can fill null value in my con list