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
salesforce instancesalesforce instance 

help to cover lines in test class

if(Trigger.isBefore && Trigger.isInsert) 
                       {
                            for(Case c : lscase)
                                {
                                 acntsIds.add(c.AccountID);
                                }
                             List<Contact> ls = new List<Contact>([SELECT id, Name, Email from Contact where AccountId IN : acntsIds]);
                             for(Contact c : ls)
                                       {
                                       conIds.add(c.Id);
                                       }   
                              for (case CaseX: lscase)
                                  {   
                                   if(!conIds.contains(CaseX.ContactID))
                                       {
                                           CaseX.addError('Please select valid Contact using Lookup Search Icon');  
                                       }
                                   
                                  }         
                                       
                       }
                       
                     if(Trigger.isAfter && Trigger.isInsert) 
                       {
                         List<Case> CasesToInsert = new List<Case>();
    
                       for (case CaseX: trigger.New)
                              {
                               Case NewCase  = new Case(Id = CaseX.Id); 
                               
                               List<User> usrList = new List<User>([SELECT id, Formula_Profiel_name__c from user where        Id = :UserInfo.getuserId() LIMIT 1]);
                               List<User> CntList = new List<user>([SELECT id, Name, Email, UserName   from User where ContactId = :CaseX.ContactID LIMIT 1]);
                         
                               for (User usr : usrList)
                               {
                                   if(Usr.Formula_Profiel_name__c == System.Label.U4_PS_Consultant) {           
                                    
                                      NewCase.PS_Owner__c = UserInfo.getuserId(); 
                                      Update NewCase;