Hot answers tagged

2

Your unit test needs to call the method: @isTest static void testScheduleMe() { Test.startTest(); ContUpdateScheduler.scheduleMe(); Test.stopTest(); } Coincidentally, this will cover the execute method as well.


2

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm Use it twice (0 1 0 15 * ?) (0 1 0 L * ?) I haven’t tried, but it should work!


2

The main problem in your code is that you're doing a DML and a callout inside of a for-loop. This is a fairly large no-no and is going to cause you to hit Governor limits very quickly. It is also going to cause the error you're seeing. Here you need to do two things: Change your code to do one DML for the entire transaction, see below for an example If the ...


2

Here you have assignment: acnt.RecordType.Name = 'Large Organisation' || acnt.RecordType.Name = 'SME/SOHO Organisation' instead of comparison: ac.RecordType.Name == 'Large Organisation' || ac.RecordType.Name == 'SME/SOHO Organisation' That is the error you're getting: "Expression cannot be assigned" The second error happens because you ask for acnt ...


2

Id <variable name>= Database.executeBatch(new <Class name>(), batch size); Example code Id batchJobId = Database.executebatch(new Batchtest() , 200); Where 200 is your scope.Scope is not mandatory. If you do not pass scope, default is 200 and maximum you can set is 2000. Note: batchJobId will contain the job Id of the batch.


1

How are you creating the test Opportunity data... in a @testSetup method? I've seen some glitchy behaviour resulting from certain combinations of unit tests + callouts + asynchronous Apex + Test.startTest()/Test.stopTest() + Test.setMock + workflow emails or Apex emails. Something confusing happens, in which the behaviour of collapsing async work into one ...


1

You need to explicitly get the list of related objects via getSObjects() method for (ScheduledBillRun__c sbr : scope) { System.debug(sbr.getSObjects('Invoices__c')); }


1

This isn't valid Apex and is not how you invoke a batch class: UpdateUserDataShedule.execute(Database.BatchableContext BC, List <User> scope); To run a batch class, create an instance of the batch and call Database.executeBatch(), just like you do in your Schedulable class: UpdateUserDataBatch u = new UpdateUserDataBatch (); Database....


1

You're missing a return type on addColdCustomerToList. Add void, for example. Also, addressColdCustomers is undefined. You should give us complete code... it feels you're missing a lot here


1

Is it allowed to fire platform event from event trigger? YES, no problem Are there any limitations of how many platform events can be fired right from event trigger? Each EventBus.publish method call is considered a DML statement, and DML limits apply. See doc. So, you could publish 10,000 events (as that is the limit for DML Rows) Publishing limits (...


1

In this line: ev.StartDateTime = Datetime.valueOf(Datetime.now().hourgmt()+24); seems that you want to add 1 day. You do not pass a date, so it resets to 1970-01-01. You should change it to: ev.StartDateTime = Datetime.now().addDays(1); Also, in DateTime dd = Datetime.valueOf(Datetime.now().hourgmt()-16); you should replace it with: DateTime dd = ...


Only top voted, non community-wiki answers of a minimum length are eligible