6

I want to know if the execute method in a batch is still called if the query in start() returns 0 records.

I put debugs in the beginning of the execute method, I know start will not return any records but i still need execute to fire.

I'm I on a fool's errand?

1
  • 5
    Why not put the logic that must run in the finish method then? – Adrian Larson Oct 26 '16 at 19:55
10

No. Execute will not be called unless at least one non-null item is available for processing. You'll have to come up with an alternative method. As a corollary to this statement, "scope" will never be empty or null, because execute won't be called if there's nothing to do.

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.