You need to sign in to do that
Don't have an account?
Gopikrishna Dasari
I have schedule apex I want to schedule for IST 8 AM and 8 AM UTC and 8 AM GMT How can we do this?
anyone can help me with this?
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
You would need to convert your time zone and consolidate in one format and execute them 3 or 4 times a day as per your requirement. Below is sample logic that executes every 4 hours in single day. Below is the format to schedule apex job. References:
https://www.desynit.com/dev-zone/salesforce-development/how-do-i-schedule-apex-programmatically/
https://medium.com/salesforce-champion/schedule-apex-salesforce-ui-and-cron-expression-asynchronous-apex-aaba0e1f981e
Please mark as Best Answer if above information was helpful.
Thanks,
Scheduling an Apex job for specific times in different time zones requires considering the time zone offsets.To schedule the job, you'll need to use the System.schedule method in Apex. Here's an example of how you could set this up:
apex
Copy code
Datetime now = Datetime.now();
Integer offsetIST = 5 * 60 + 30; // IST offset in minutes
Datetime targetTimeIST = Datetime.newInstance(
now.year(), now.month(), now.day(),
8, 0, 0
).addMinutes(-offsetIST);
Datetime targetTimeUTC = Datetime.newInstance(
now.year(), now.month(), now.day(),
8, 0, 0
);
// Schedule the jobs
String jobNameIST = 'MyJobIST';
String jobNameUTC = 'MyJobUTC';
System.schedule(jobNameIST, CronExpressionGenerator(hour = targetTimeIST.hour(), minute = targetTimeIST.minute()));
System.schedule(jobNameUTC, CronExpressionGenerator(hour = targetTimeUTC.hour(), minute = targetTimeUTC.minute()));
In this example, CronExpressionGenerator is a hypothetical method to create a Cron expression with the given hour and minute.
By following these steps, you'll have your Apex job scheduled to run at 8 AM in IST, UTC, and GMT. Just make sure to replace the example code with your actual job implementation and proper scheduling syntax.
Remember to consider daylight saving time changes if applicable to the time zones you're working with.
I hope this helps you achieve your scheduling requirements! If you have any further questions, feel free to ask.
Follow My Health (https://www.followmy-health.com/)
Schedule it at 8 AM UTC in Salesforce.
Calculate the equivalent times: 1:30 PM IST and 8 AM GMT.
Schedule additional jobs at those calculated times for IST and GMT.
Also visit my website (https://athgardens.com/).