+ Start a Discussion

@future - can't pass lists/arrays

So I have an Opportunity which could potentially have over 100 line items.  I have a trigger that updates all Line Items (actually all related products - long story), when the Opportunity is updated to Closed Won.  Works perfectly up to 100 records, then fails.  So I updated the code to use the @future, only to learn that you can't pass Lists to @future methods.  So what's the solution to this?  I found several posts on these forums about this, but I haven't seen an answer to this.  Is this just an absolute limit and there's nothing I can do about it?

Vijay RautVijay Raut
Hi Chris,

If i am getting you correctly then you are trying to send list of Opportunity SObjects (may be Trigger.new or Trigger.old) to your future method / or may be you are sending line items SObject List. Is that correct?

If you are doing so, then we have limitation that we cannot pass list of SObject to future method. So what i would suggest that, create temporary list of String which would hold Ids of record (which you are sending to Future method as a List). And send that ID (String) List to future method.

And then in Future method, using SOQL, fetch the data for those Id's.

Hope this would help.

Hello VR. 

What you suggest above was my solution.  I actually had to pass some additional values as well, so I constructed an array of delimited strings - then took everything apart and built objects in the @future method.

Many thanks for your resopnse.