• bhagya manshani
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies

// Here is my Apex class........

 

   global  class schedule_class  implements Schedulable  {
   
        //public static String CRON_EXP = '0 0 20 * * ? 2010';     //'0 0 0 3 9 ? 2022'
     global void execute(SchedulableContext ctx)
     {
     
        System.debug('**************************************');
      }
 }

// End of Class

 

// Here is my test method to call that class

 

  @isTest
private class mergeNumbers {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        schedule_class m = new schedule_class();
        String sch = '20 30 8 10 2 ?';
        system.schedule('Merge Job', sch, m);
    }
}

// My Question  is : When i test this method on that Execute () is not Covering Or we can say that not able to get execute()

   Please Help...............Dear Thanks a lot in Advance plz    

I'm having trouble sending out an email message if I use an adderror. I've read in the apex docs that its not processing since the adderror does not allow the tranaction to commit. Knowing this is the case, what alternatives do I have?

 

Ultimately, I want to prevent a user from deleting a contact when there are licenses and I also want to be notified that the action has taken place. I think I might have to get creative for this. Here is the trigger I have so far:

 

 

trigger PreventDelete on Contact (before delete) {
for (License__c l : [select contact__c from license__c
where contact__c in :Trigger.oldMap.keySet()]) {

//Setup email and send
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'email@acme.com'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('emaiL@acme.com');
mail.setSenderDisplayName('Salesforce Support');
mail.setSubject('Contact Deletion Attempted');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('A contact delete was attempted.');
mail.setHtmlBody('Review contact for deletion<p>'+
' View license<a href=https://na5.salesforce.com/l.id>click here</a>');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

Trigger.oldMap.get(l.contact__c).addError('Contact has licenses attached. Support has been notified.');
}
}

 

 

 

email@acme