2

I have a batch class where i need to grab the records sequentially.

It looks like if i am querying regularly in salesforce and system.debugging the outputs, the records do not seem to be in any specific order.

If i change my query to order by name (which is an autonumber field) will this pass the records in the correct order to my class?

Edit:I have tested using order by and it orders each batch individually but it may run like

  • batch 1 - [0-100]
  • batch 2 - [400-500]
  • batch 3 - [300-400]
  • batch 4 - [200-300]
2
  • I've deleted my answer, since there's obviously something going on. My suggestion would be a Queueable that you chain in order to control record order.
    – sfdcfox
    Mar 17, 2020 at 16:33
  • could you give me a code example of that solution? I will write that and test it
    – Tim Willis
    Mar 17, 2020 at 16:34

0

You must log in to answer this question.

Browse other questions tagged .