You need to sign in to do that
Don't have an account?
Inbox Outbox
Can someone give me the syntax/ code of a schdulable class invoked from a trigger and the test class as well.?
Greetings!
Please give the class code and also the trigger code completely include the CRON expression.
I don't know the syntax of how to invoke a trigger and then test it to run.
I just need the syntax to go by.
I'd appreciate the scenario of creating account from lead (account name with the lead's last name.
Thanks a ton!
Hi,
You can take reference from the below.
Requirement : "I have Batch apex Class and Schedulable class. I am looking for the syntax to call the Batch apex class from the trigger or calling the schedulale class from Trigger, which inturn calls the Batch apex."
Ans :
The syntax for launching a Batch Apex job from a Trigger is the same as launching it from anywhere else in Apex.
Here's the syntax for launching your Scheduled Class, assuming it has a constructor:
I would be very careful, though, about launching your scheduled Job from a trigger, as you NEED, NEED to check to make sure that you have available Scheduled Jobs --- you can only have 10 Scheduled Jobs at a given time. Use something like this to check to make sure you have enough Jobs:
As far as launching Batch Apex jobs, I usually have a utility method in my Batch classes that makes it easy to launch a new Batch Job, i.e.
Link : https://salesforce.stackexchange.com/questions/148270/how-can-i-call-a-schedule-class-from-trigger-before-the-due-date-c-field
Link 2: https://salesforce.stackexchange.com/questions/22590/how-can-i-call-a-schedule-class-execute-method-from-normal-apex-class-or-apex-tr/26935
Link 3: Reference fro test class also
http://theblogreaders.com/write-schedule-apex-class-test-class-salesforce/
Please mark it as the best answer so that other people would take reference from it.
Thank You