You need to sign in to do that
Don't have an account?
Ankit Bhati 20
How to access wrapper class list in another method in lightning
Hi Everone
I want to access wrapper list in handledelete method but it found null can anyone suggest how to access wrapper in another method.
public class recordOfAccount {
@AuraEnabled
public static List<recAccountChildCls> oRecAccountChildCls{get;set;}
public recordOfAccount(){
oRecAccountChildCls = new List<recAccountChildCls>();
system.debug('calling constractor');
}
@AuraEnabled
public static List<recAccountChildCls> recAccount(){
system.debug('calling');
Boolean serialNumber = false;
integer i =0;
oRecAccountChildCls = new List<recAccountChildCls>();
List<Account> accountlist = new List<Account>([select id,Name,Phone,Industry from Account limit 100]);
for(Account oAccount : accountlist){
oRecAccountChildCls.add(new recAccountChildCls(oAccount,serialNumber));
i++;
}
system.debug('oRecAccountChildCls'+oRecAccountChildCls);
return oRecAccountChildCls;
}
@AuraEnabled
public static void recSave(string nm ,string ph){
system.debug('name from front end....'+nm);
system.debug('phone from front end....'+ph);
Account oAccount = new Account();
oAccount.Name = nm;
oAccount.Phone = ph;
insert oAccount;
}
@AuraEnabled
public static void handledelete(){
for(recAccountChildCls oAccount : oRecAccountChildCls){
system.debug('oRecAccountChildCls size'+oAccount.srNum);
}
}
public class recAccountChildCls{
@AuraEnabled
public Account ac{get;set;}
@AuraEnabled
public boolean srNum{get;set;}
public recAccountChildCls(Account acObj,boolean srNumber){
ac = new Account();
ac = acObj;
srNum = srNumber;
}
}
}
I want to access wrapper list in handledelete method but it found null can anyone suggest how to access wrapper in another method.
public class recordOfAccount {
@AuraEnabled
public static List<recAccountChildCls> oRecAccountChildCls{get;set;}
public recordOfAccount(){
oRecAccountChildCls = new List<recAccountChildCls>();
system.debug('calling constractor');
}
@AuraEnabled
public static List<recAccountChildCls> recAccount(){
system.debug('calling');
Boolean serialNumber = false;
integer i =0;
oRecAccountChildCls = new List<recAccountChildCls>();
List<Account> accountlist = new List<Account>([select id,Name,Phone,Industry from Account limit 100]);
for(Account oAccount : accountlist){
oRecAccountChildCls.add(new recAccountChildCls(oAccount,serialNumber));
i++;
}
system.debug('oRecAccountChildCls'+oRecAccountChildCls);
return oRecAccountChildCls;
}
@AuraEnabled
public static void recSave(string nm ,string ph){
system.debug('name from front end....'+nm);
system.debug('phone from front end....'+ph);
Account oAccount = new Account();
oAccount.Name = nm;
oAccount.Phone = ph;
insert oAccount;
}
@AuraEnabled
public static void handledelete(){
for(recAccountChildCls oAccount : oRecAccountChildCls){
system.debug('oRecAccountChildCls size'+oAccount.srNum);
}
}
public class recAccountChildCls{
@AuraEnabled
public Account ac{get;set;}
@AuraEnabled
public boolean srNum{get;set;}
public recAccountChildCls(Account acObj,boolean srNumber){
ac = new Account();
ac = acObj;
srNum = srNumber;
}
}
}
Hi Ankit,
ParentClass.WrapperClass is how you can access a wrapper class from outside the main class. Sharing an example code snippet below
Cann't we access wrapper class in another method that define in same class like as shown in code.while I am using oRecAccountChildCls in handledelete method it shows null; Could you please elaborate workaroundnd