I'd like to query a list of IDs at one point.... save it temporarily.... then use that list in a future Apex process later. Is there a way to do that?
1 Answers
Lots of options to choose from, would help to know more about your use case or some pseudocode. It can be something simple, it can be some full-blown producers-consumers pattern. There's even a concept called "unit of work" but it might be an overkill for you.
If you're coming from java background - Apex's static behaves differently. In Java/Tomcat/whatever statics survive between page loads, it's truly class variable visible by all users/processes/whatevers. In Apex if you mark something static it'll be wiped from memory anyway when the transaction ends.
If it's really for @future
method, a Queueable or batch job - you can just call it passing Set?
You can always call something like
insert new Task(
Subject = 'stuff to process',
Description = String.join(myIds, '\n')
);
and then have something else querying for these tasks, processing them and deleting (or marking as complete?) when done. Up to you whether it'll be a Task or custom object or a txt file (saved as ContentVersion), doesn't matter much. Maybe even "big Object"
You could store something in Platform Cache. Probably not best idea if you need to guarantee processing but it's there.
You could look into some event-driven architecture. Have API/Flow/Apex raise platform events and then subscribe to them (also with API/Flow/Apex). API access could even replay events up to 72h back. Flows and Apex couldn't do it but still (in Apex you'd write an after insert trigger almost as if it's normal object, it is a way of detaching)

- 18,088
- 2
- 34
- 46