0

I have a scheduled batch that runs every 3 minutes. That batch will pick records when the last modified date is lesser than 2 minutes from the current time. The records falling in the criteria will be sent for deletion of some related records and then sent to other system.

When the record is updated at say 10:20, deletion has happened at 10:21 and callout log is created at 10:23. Ideally deletion and log should be in the same time or can be some less difference in seconds.

Is user's timezone will be an issue?

Query criteria for records.

DateTime timeframe = Datetime.now().addMinutes(-2);
query = 'select id from contact where lastmodifieddate < timeframe';
2
  • So, do you have any issues? Or just asking here instead of basic testing of that use case which is straightforward to reproduce? – kurunve Jun 1 '17 at 11:21
  • Perhaps convert the timezone of all relevant time inputs to one timezone so that wall clock time doesn't matter, which it doesn't, just the passing of time does – Recct Jun 1 '17 at 11:22
0

This issue is because:

batch job is an asynchronous process. It will execute when resources will be available on multi tenant environment of Salesforce.

We can not ensure that the records that the batch job has picked, will be executed in the same minute. So, the time difference is possible for sure.

Documentation says:

Force.com asynchronous processing makes a best effort to complete requests as quickly as possible, however there are no guarantees on wait or processing time.

https://developer.salesforce.com/page/Asynchronous_Processing_in_Force_com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.