• Ankit Bhati 20
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
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;
            
            
        }
    }
}
  • We have standard "Contact" object in SFDC.
  • You have to add one Field in Contact Object that is "Total Family Members" type is Number(2,0):
  • Let Account be the Family. So if there are 5 Contacts belongs to same account, that means these all 5 belongs to same family.
What you have to do:                 
  • Create a trigger on Contact to calculate "Family Members Count".
    • Create one Account: Create New Contact as a child for it. Then Contact's "Total Family Member" will have value 1.
    • Create another Contact for the same Account then Both Contact should have value 2 for "Total Family Member Field".
    • if someone changes contact's family like : changing account lookup value for a contact, then Both family will reflect. Because one family member is removed from one family and added to new Family. values should be updated: 
      •  All Contact's of Older Family should now have the "Total Family Member" value decreased by1. 
      • And for new family all Contact's "Total Family Member" will have value increased by1.