New answers tagged

2

The only downside is that this may not work for callouts that you need to make from a trigger, because of the 100 scheduled job limit (you can't have more than 100 pending jobs scheduled). A more elegant solution would store pending requests in a queue of some sort, and call itself every few minutes or so. The reason why many designs are "vaguely complicated ...


4

In your execute query you are looking for records where Leadsource is null but you are populating it in the test data. Please make sure to create the test data in the test class according to the query in the Scheduler I.e marking Leadsource as null or blank. Also, in the test class, I would suggest to put the asserts after the Test.stoptest statement.


4

There are multiple ways. Quick and dirty: do an if on the query and return today's records if is running test, return 3 days ago otherwise. (Be careful with timezone differences, and tests running at around mid-night) Using Test.loadData() Using JSON.deserialize() some more guided steps are given on this post I personally like option 2, as it allows you ...


1

The only "schedule X from now" is for Batchable: System.scheduleBatch(new BatchClassImpl(), 'Near Future', 5); This would schedule a job five minutes from now to run the batch job. For anything else, you would indeed want to build your own cron string, which shouldn't be more than a dozen lines of code in most cases; you could even write a utility method ...


Top 50 recent answers are included