• Sandeep Kumar 84
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
Hi All, 

I have a problem, where im calling a method in a controller from a button on a visual force page. The controller updates some records but the trigger that i have which is an after update doesnt fire (well acutally it seems like its firing at random there are a good few hundred records) has anyone else had this problem and know how to solve the issue? thanks.
I have a trigger whose code coverage is 56% in Sandbox , however while deploying in PROD the code coverage is reported as 0%.
Please help meto circumvent this issue, so that I can deploy the trigger in PROD
How to increase the code coverage for the following code - I'm getting an error while deploying this trigger on PROD - SendEmailForTaskEscalation, Details: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required :

trigger SendEmailForTaskEscalation on Task (after update) {
    
    for (Integer i = 0; i < Trigger.new.size(); i++) {
         try{
             
             if( Trigger.new[i].CallDisposition == 'Escalated to Manager' &&
                 Trigger.new[i].Status != 'Completed'  &&
                 Trigger.new[i].ActivityDate <= date.today()
               ) {
           
                     sendEmailToManager(Trigger.new[i]);  
                     System.debug('SendEmailForTaskEscalation -> Email Send to Manager'); 
               }else{
                   
                   System.debug('SendEmailForTaskEscalation -> Email Not Send to Manager'); 
               }
         }catch(Exception e)
         {
            Trigger.new[i].addError(e.getMessage());
            System.debug('Error : SendEmailForTaskEscalation ->'+ e);  
         }
    }
    
    // This method will submit the proposal automatically
    public void sendEmailToManager(Task tsk){
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String ownerName = [select Name from User where Id = :tsk.OwnerId].Name;
        String emailAddr = [select Email from User where Id = :tsk.OwnerId].Email;
        String userManagerId = [select ManagerId from User where Id = :tsk.OwnerId].ManagerId; 
        String userManager = [select Name from User where Id = :userManagerId].Name;
        String userManagerEmail = [select Email from User where Id = :userManagerId].Email;
        
        String[] toAddresses = new String[] {userManagerEmail};
        String[] ccAddresses = new String[] {emailAddr};    
        mail.setToAddresses(toAddresses);
        mail.setCcAddresses(ccAddresses); 
        
        mail.setSubject('SLA breach for the Task assigned to the User : ' + ownerName );
        mail.setHtmlBody('<br/>Hi,<br/><br/>This is to inform you that, ' + ownerName + ' has failed to complete the following task within the due date :<br/><br/> Due Date of the task :' +tsk.ActivityDate+'<br/>'+'Priority of the task : <b>' + tsk.Priority + '</b><br/> Subject : <b>' +  tsk.Subject  + '</b>'+'</b><br/> Description : <b>' +  tsk.Description +'</b>'+'</b><br/> Status : <b>' +  tsk.Status  + '</b> <br/><br/><br/>Thanks & Regards <br/> <br/>Salesforce Administrator');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

        
    }
    
          
}
I'm doing a proof of concept for some dashboards we are going to be displaying on monitors around the office. I'm trying to get the Highcharts example into a visualforce page to show what it is capable of but the page won't display anything and I don't know why. It's such a simple page but I'm not a javascript developer and I'm pulling my hair out.

<apex:page sidebar="false" showHeader="false"  >
<apex:includeScript value="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" />
<apex:includeScript value="http://code.highcharts.com/highcharts.js" />
<apex:includeScript value="http://code.highcharts.com/modules/exporting.js" />
    
    <script type="text/javascript">
    $(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Fruit Consumption'
        },
        xAxis: {
            categories: ['Apples', 'Bananas', 'Oranges']
        },
        yAxis: {
            title: {
                text: 'Fruit eaten'
            }
        },
        series: [{
            name: 'Jane',
            data: [1, 0, 4]
        }, {
            name: 'John',
            data: [5, 7, 3]
        }]
    });
});
</script>

  <div id="container"  style="height: 400px;" > </div>
 
</apex:page>
  • March 12, 2014
  • Like
  • 0