function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SRILAKSHMI BSRILAKSHMI B 

How to pass List of opportunities to the @future method

Hi,

 

I have requirement where I want to send list of opportunity records from trigger to the @future method.Since in @future method sobjects cannot be passed as parameters, can anyone please suggest how to access this list inside the @future method.

 

 

 

Thanks,

Srilakshmi B

bob_buzzardbob_buzzard

You can pass an array of primitives to an @future method.  Could you capture the ids of the opportunities as Strings, store in a list and then retrieve the full objects via a SOQL call in the @future method?

alexbalexb

I concur with Bob, but I was doing this last week using a List<Id, Id> structure. The ID type is a primitive type in Apex:

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_primitives.htm

 

Pradeep_NavatarPradeep_Navatar

If you want to pass list in @future method then you can can pass records individually  :

 

                                                public List<opportunity> opp{get;set;}

                                                opp = [select id,name from opportunity];

                                                checkGroup(opp[0].id, opp[0].name);

                                                @future

                                                  public static void checkGroup(Id conn,String El)

                                                  {

 

                                                                 opportunity oppt = new opportunity(Id=conn);                                               

                                                                 oppt.Registration_Status__c='Registered';

                                                                 oppt.Name = El ;

                                                                 update oppt;

                                                  }