function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
global class scheduledBatchable implements Schedulable { global void execute(SchedulableContext sc) { Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {message}; list<opportunity> opp = [SELECT id, name FROM opportunity WHERE createddate = TODAY]; if(opp.size() == 0){ Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage(); // Set recipients message.toAddresses = new String[] { 'Admin@gmail.com' }; message.optOutPolicy = 'FILTER'; message.subject = 'Opportunity Not created'; message.plainTextBody = 'Opportunity Not created.Please create'; messages.add(message); Messaging.SendEmailResult[] results = Messaging.sendEmail(messages); if (results[0].success) { System.debug('The email was sent successfully.'); } else { System.debug('The email failed to send: ' + results[0].errors[0].message); } } } }
@isTest private class scheduledBatchable_Test{ static testMethod void test_execute_UseCase1(){ List<Opportunity> opportunity_Obj = [SELECT Id,Name,StageName,CreatedDate from Opportunity]; System.assertEquals(true,opportunity_Obj.size()==0); scheduledBatchable obj01 = new scheduledBatchable(); String CRON_EXP = '0 0 0 3 9 ? 2022'; system.schedule('Test Territory Check', CRON_EXP, obj01); } }
Please check following sample code, I have not tested may you will get some syntactical errors.
You need to above schedule class daily.
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
All Answers
Please check following sample code, I have not tested may you will get some syntactical errors.
You need to above schedule class daily.
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
change to
Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage>();