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
Deepak agarwal 9Deepak agarwal 9 

Wrapper class help.

Hi Folks,
 I am writting a wrapper class in which it returns 2 lists.Pls refer the code.
Public class SFDC_Ltng_StakeHolderWrapperClass{
   @AuraEnabled
    Public static SFDC_Ltng_StakeHolderWrapperClass getmethod(){
        SFDC_Ltng_StakeHolderWrapperClass Slswc=new SFDC_Ltng_StakeHolderWrapperClass();
        List<ZenObject__c> ZenobjsEven;
        List<ZenObject__c> ZenobjsOdd;        
        List<ZenObject__c> Zenobjs=[Select ZenLms_Name_del__c,ZenLms_SubText__c from ZenObject__c];
        for(integer i=1;i<=Zenobjs.size();i++){
            if(math.mod(i,2)==0){
                Slswc.ZenobjsEven.addAll(Zenobjs);
               
            }
            else if(math.mod(i,2)!=0)
                Slswc.ZenobjsOdd.addAll(Zenobjs);
            
        }       
       
       return Slswc; 
}
    
}

But i doing some mistake here.As i have less idea on wrapper class.
Critera here is  if(math.mod(i,2)==0){
                            //then i am adding Zenobjs lists to ZenobjsEven
                            else to ZenobjsOdd
}
atlast i need to return 2 lists.
Can anybody help me out here.
Best Answer chosen by Deepak agarwal 9
Dasetti Venkata RamaiahDasetti Venkata Ramaiah
public class SFDC_Ltng_StakeHolderWrapperClass{
   @AuraEnabled
    Public static MywrappTwoList getmethod(){
        MywrappTwoList Slswc=new MywrappTwoList ();
        list<ZenObject__c> ZenobjsEven = new list<ZenObject__c>(); 
        list<ZenObject__c> ZenobjsOdd = new list<ZenObject__c>();     
        List<ZenObject__c> Zenobjs=[ZenLms_Name_del__c,ZenLms_SubText__c from ZenObject__c];
        for(integer i=0;i<=Zenobjs.size();i++){
            if(math.mod(i,2)==0){
               ZenobjsEven.add(Zenobjs[i]);
               
            }
            else if(math.mod(i,2)!=0)
                ZenobjsOdd.add(Zenobjs[i]);
            
        }      
        
        if(!ZenobjsEven.isEmpty()){
          Slswc.ZenobjsEven = ZenobjsEven;
        }
         if(!ZenobjsOdd.isEmpty()){
          Slswc.ZenobjsOdd= ZenobjsOdd;
        }
       
       return Slswc; 
}
 Public class MywrappTwoList {
     public list<ZenObject__c> ZenobjsEven{get;set;}
     public list<ZenObject__c> ZenobjsOdd {get;set;}
          
 }   


}