• Adminuser
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi,
can any one help test class for following trigger
trigger CaseMilestone on Case (after update) {
    try{        
        set <Id> caseIds =new  set <Id>();
        list<Commision__c> Comlist =new  list<Commision__c>();        
        for(case c:trigger.new)
        {
            if(c.Status == 'closed' && c.Milestone_Approval_Status__c ==TRUE){
                caseIds.add(c.id);  
            }
        } 
        system.debug('caseIds :'+caseIds);
        
        List<CaseMilestone> cmsToUpdate = [select Id, completionDate,MilestoneTypeId,CreatedById,BusinessHoursId,CaseId,ElapsedTimeInDays,ElapsedTimeInHrs,IsCompleted,IsViolated  from CaseMilestone cm  where caseId in :caseIds /* and cm.MilestoneType.Name=:Milestone2 */ and completionDate != null limit 1];
        system.debug('cmsToUpdate :'+cmsToUpdate); 
        for(CaseMilestone cm :cmsToUpdate)
        {
            Commision__c com = new Commision__c();
            com.Case__c = cm.CaseId;
            com.OwnerId =cm.CreatedById;
            com.Owner__c=cm.CreatedById;
            com.IsCompleted__c=cm.IsCompleted;
            com.CompletionDate__c=cm.completionDate;   
            com.Milestone_Name__c=cm.MilestoneTypeId;
            Comlist.add(com);
        }
        insert Comlist;
           
        system.debug('Comlist :'+Comlist); 
    }
    catch (Exception e){
        system.debug('Exeption ::'+e + 'Line Number ::' +e.getLineNumber() + 'getCause ::' +e.getCause()+ 'getMessage ::'+e.getMessage());
    }
}

Thanks,
Hi,
can any one help test class for following trigger
trigger CaseMilestone on Case (after update) {
    try{        
        set <Id> caseIds =new  set <Id>();
        list<Commision__c> Comlist =new  list<Commision__c>();        
        for(case c:trigger.new)
        {
            if(c.Status == 'closed' && c.Milestone_Approval_Status__c ==TRUE){
                caseIds.add(c.id);  
            }
        } 
        system.debug('caseIds :'+caseIds);
        
        List<CaseMilestone> cmsToUpdate = [select Id, completionDate,MilestoneTypeId,CreatedById,BusinessHoursId,CaseId,ElapsedTimeInDays,ElapsedTimeInHrs,IsCompleted,IsViolated  from CaseMilestone cm  where caseId in :caseIds /* and cm.MilestoneType.Name=:Milestone2 */ and completionDate != null limit 1];
        system.debug('cmsToUpdate :'+cmsToUpdate); 
        for(CaseMilestone cm :cmsToUpdate)
        {
            Commision__c com = new Commision__c();
            com.Case__c = cm.CaseId;
            com.OwnerId =cm.CreatedById;
            com.Owner__c=cm.CreatedById;
            com.IsCompleted__c=cm.IsCompleted;
            com.CompletionDate__c=cm.completionDate;   
            com.Milestone_Name__c=cm.MilestoneTypeId;
            Comlist.add(com);
        }
        insert Comlist;
           
        system.debug('Comlist :'+Comlist); 
    }
    catch (Exception e){
        system.debug('Exeption ::'+e + 'Line Number ::' +e.getLineNumber() + 'getCause ::' +e.getCause()+ 'getMessage ::'+e.getMessage());
    }
}

Thanks,
Can any one explain what is 'ap1' in 'https://ap1.salesforce.com' Note: I am accessing from India. Thanks in advance, Kiran.