You need to sign in to do that
Don't have an account?
Tyler McCarty
Dynamic scheduler class
So the requirement is to build a way for users to be able to schedule emails to go out at certain times. So what I have done is built a custom object called EmailScheduler__c and gave it fields such as Recipients__c, Time__c, Subject__c, Body__c, FileName__c, ClassName__c, etc. I have then made a trigger that will run after inserting a new record of EmailScheduler__c and it will grab the information for that new object.
Where I'm stuck at is how do I setup the scheduler class from the trigger. I know I can setup a dynamic scheduler and a dynamic emailGenerator class but how do I set that up to run, and when the user deletes a record would it delete the schedule on the backend?
Where I'm stuck at is how do I setup the scheduler class from the trigger. I know I can setup a dynamic scheduler and a dynamic emailGenerator class but how do I set that up to run, and when the user deletes a record would it delete the schedule on the backend?
my suggestion is to write an apex class that uses the schedulable-interface (trailhead: https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_scheduled). You can schedule the job by defining a cronjobs syntax in that batch job.
To start this job the first time use the developer console and anonymous code (debug > open execute anonymous window)
Feel free to ask in more detail about my suggested solution and if you need more information.
Regards,
Chris
unfortunately it looks like some answers from you were changed or are deleted in comparison to the email notifications I've received.
I saw a snapshot for apex code which triggers a batch class in an trigger. In summary: It is not a good practice to call batches from a trigger: https://salesforce.stackexchange.com/questions/31000/is-it-advisable-to-call-batch-from-trigger (think about limitations and governour limits).
I'm afraid I don't understand the implementation. It sound a bit unusual.
Why do you have two scheduler classes? One suggestion / approach is to handover all processed record ids and the schedulable class should do the logic.
Regards,
Chris
Perhaps it is also a solution to subscribe to an standard-report.
Please mark one answer as best answer if I fulfill your requirement.
Regards,
Christian