• fiona gentry
  • NEWBIE
  • 320 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 51
    Questions
  • 19
    Replies
Dear pals,

I have a detailed page and i need to show / hide email and phone number, based on checkbox selection...how can i do that?

Your help is highly appreciated

Fiona
How do i resolve a flow error 

I have a  flow which calls an apex class and here is execution logs error
Error Occurred During Flow "ServiceAppointment_API": An Apex error occurred: System.AsyncException: 

Warning: Approaching hourly email limit for this flow.
Each flow in your organization is limited to 100 error emails per hour. Since 12:00 PM, Salesforce has sent 99 error emails for ServiceAppointment_API flow. After 100 emails, Salesforce suppresses all error emails for this flow. The limit resets at 1:00 PM.
Error element myWaitEvent_myWait_myRule_3_event_0_SA1 (FlowActionCall).
An Apex error occurred: System.AsyncException: You've exceeded the limit of 100 jobs in the flex queue for org 00D36000000rhGR.
 Wait for some of your batch jobs to finish before adding more. To monitor and reorder jobs, use the Apex Flex Queue page in Setup.

 
Dear Pals,

How to resolve Developer script exception just by looking at logs below,
any suggestion what might be the solution to this error logs
 
Developer script exception  : 'FSL.FeatureTracking' for job id '7071Q0000CbEUR8' :
Unable to save value: totaNumOfActiveRes for subscriber org: 00D36000000rhGR save failed with error: Error [statusCode=UNABLE_TO_LOCK_ROW, code=[xmlrpc=132...

Apex script unhandled exception by user/organization: 00536000008HQDp/00D36000000rhGR

Failed to invoke future method 'private static void updateAllFutureBasedFMAParameters()' on class 'FSL.FeatureTracking' for job id '7071Q0000CbEUR8'

caused by: System.UnexpectedException: Unable to save value: totalNumOfActiveRes for subscriber org: 00D36000000rhGR save failed with error: 

Error [statusCode=UNABLE_TO_LOCK_ROW, code=[xmlrpc=1325, statusCode=UNABLE_TO_LOCK_ROW, exceptionCode=UNABLE_TO_LOCK_ROW, 
scope=PublicApi, http=500], message=unable to obtain exclusive access to this record, fields=null]

Regards,
Fiona

 
Dear Pals,

How to write system.assert for SOQL Containing Most Recent List view of Cases

Here is test class where i want to write system.assert
@isTest
   static void testListView()
   {
        test.starttest();
        List<ListView> views = ERT_MultiLevelSelectEdit.getListViews();
        test.stopTest();
       
    }

Here is apex class
 
@AuraEnabled
public static List<ListView> getListViews() {
    List<ListView> listviews =
        [SELECT Id, Name FROM ListView WHERE SobjectType = 'Case' and Name='Recently Viewed Cases'];

  
    return listviews;
}

Your help is needed and appreciated

Regards,
Fiona
Dear Pals,

I need to  Fire ShowNavigateToList After ShowToast On Single Save Function Of JS file,somehow only ShowToast working and not the ShowNavigateToList,Here is  what i have written for Save button,basically after the record is Upserted i want the page to move to ListView,what change is needed below
 
onConfirm:function(component, event, helper){
        var picklist=component.find('ddLevel1');
        var picklistvalue=picklist.get('v.value');
        var picklistdep=component.find('ddLevel2');
        var picklistvaluedep2=picklistdep.get('v.value');
        var picklistoldL1=component.get('v.oldL1');
        var picklistoldL2=component.get('v.oldL2');
        var picklistoldL3=component.get('v.oldL3');
        var ertrecordGuid=component.get('v.ertGUID');
        var picklistdep3=component.find('ddLevel3');
        var picklistvaluedep3=picklistdep3.get('v.value');
        var action = component.get("c.savecasetype");
       
        action.setParams({  'level1' : picklistvalue,
                          'level2' : component.get('v.secondlevelselected'),
                          'level3' : picklistvaluedep3,
                          'oldlevel1' : picklistoldL1,
                          'oldlevel2' : picklistoldL2,
                          'oldlevel3' : picklistoldL3,
                          'guid':ertrecordGuid,
                          'id' : component.get("v.recordId")});
        
        
        var toastEvent = $A.get("e.force:showToast");
        action.setCallback(this, function(e) {
            if(e.getState()=='SUCCESS'){
                var result=e.getReturnValue();
                        
                
                if(result==='successfull'){
                    toastEvent.setParams({
                        "title": "Success!",
                        "message": "The record has been Upserted  successfully."
                         
                    });
                    
                    toastEvent.fire();
                   
                }else{
                   
                    toastEvent.setParams({
                        "title": "Error",
                        "message": "The record has not been Upserted  successfully."
                    });
                    toastEvent.fire();
                }
            }
            
            
          
             $A.get('e.force:refreshView').fire(); 
             
        });
        
           var action = component.get("c.getListViews");
    action.setCallback(this, function(response){
        var state = response.getState();
        if (state === "SUCCESS") {
            var listviews = response.getReturnValue();
            var navEvent = $A.get("e.force:navigateToList");
            navEvent.setParams({
                "listViewId": listviews.Id,
                "listViewName": null,
                "scope": "Case"
            });
            navEvent.fire();
        }
    });
        $A.enqueueAction(action);
        
          
        
    }

Here is ListView controller
 
@AuraEnabled 

public static List<ListView> getListViews() { 

    List<ListView> listviews = 

        [SELECT Id, Name FROM ListView WHERE SobjectType = 'Case' and Name='Recently Viewed Cases']; 

  

   

    return listviews; 

}



Your help is needed and appreciated
Regards,
Fiona​​​​​​​

 
Hi Pals,

I have Salesforce lightning component which edits a Multi level picklist and then after clicking Save ,This modal is shown up again
User-added image

,Now instead of the same above modal after i click Save ,i would like to redirect to Case List View,

User-added image

I wrote the below code in JS for save Button, but still i see the same Modal screen and not the redirect
 
  onConfirm:function(component, event, helper){
        var picklist=component.find('ddLevel1');
        var picklistvalue=picklist.get('v.value');
        var picklistdep=component.find('ddLevel2');
        var picklistvaluedep2=picklistdep.get('v.value');
        var picklistoldL1=component.get('v.oldL1');
        var picklistoldL2=component.get('v.oldL2');
        var picklistoldL3=component.get('v.oldL3');
        var ertrecordGuid=component.get('v.ertGUID');
        var picklistdep3=component.find('ddLevel3');
        var picklistvaluedep3=picklistdep3.get('v.value');
        var action = component.get("c.savecasetype");
       
        action.setParams({  'level1' : picklistvalue,
                          'level2' : component.get('v.secondlevelselected'),
                          'level3' : picklistvaluedep3,
                          'oldlevel1' : picklistoldL1,
                          'oldlevel2' : picklistoldL2,
                          'oldlevel3' : picklistoldL3,
                          'guid':ertrecordGuid,
                          'id' : component.get("v.recordId")});
        
        
        var toastEvent = $A.get("e.force:showToast");
        action.setCallback(this, function(e) {
            if(e.getState()=='SUCCESS'){
                var result=e.getReturnValue();
                        
                
                if(result==='successfull'){
                    toastEvent.setParams({
                        "title": "Success!",
                        "message": "The record has been Upserted  successfully."
                         
                    });
                     var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
      "url": "lightning/o/Case/list?filterName=Recent"
    });
    urlEvent.fire();
                    toastEvent.fire();
                   
                }else{
                   
                    toastEvent.setParams({
                        "title": "Error",
                        "message": "The record has not been Upserted  successfully."
                    });
                    toastEvent.fire();
                }
            }
          
             $A.get('e.force:refreshView').fire(); 
             
        });
        $A.enqueueAction(action);
        
          
        
    }

Any help on this is highly appreicated

Regards,
Fiona

 
Hi Pals,

This  test cass keeps throwing an error for

1) For Method "testGetLevel1 " as
System.AssertException: Assertion Failed: Expected: Test Level 1, Actual: null
1) For Method "testsaveCaseType" as
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Level 1: bad value for restricted picklist field: Test Level 1: [Level_1__c]

Here is test class
 
@isTest
public class ERT_MultiLevelSelectEditTest {
  
  @testSetup static void setup() {
        
    Case_Type_Data__c ct = new Case_Type_Data__c();
    ct.Level_1__c = 'Test Level 1';
    ct.Level_2__c = 'Test Level 2';
    ct.Level_3__c = 'Test Level 3';
    insert ct; 

    }
    
  @isTest
   static  void testGetLevel1()
   {
    
    Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
    insert cas;
    ERT_Case_Type__c  obj = new ERT_Case_Type__c ();
    obj.Level_1__c = 'Test Level 1';
    obj.Level_2__c = 'Test Level 2';
    obj.Level_3__c = 'Test Level 3';
    obj.Case__c = cas.id;
    upsert obj;
       
   test.startTest();
   List<ERT_MultiLevelSelectEdit.LevelWrapper> lstWrapper= ERT_MultiLevelSelectEdit.getLevel1(obj.id);
   test.stopTest();
   system.assertEquals('Test Level 1', lstWrapper[0].strL1val);
     
   
     
    

   }

  @isTest
   static void testGetLevel2()
   {
   test.startTest();
   List<String> s = ERT_MultiLevelSelectEdit.getLevel2('Test Level 1');
   test.stopTest();
   system.assertEquals('Test Level 2', s[0]);
      
   

   }
    
  @isTest
   static void testGetLevel3()
   {
    test.startTest();
    List<String> s = ERT_MultiLevelSelectEdit.getLevel3('Test Level 1','Test Level 2');
    test.stopTest();
    system.assertEquals('Test Level 3', s[0]);
   }
    
  @isTest 
   static  void testsaveCaseType(){
   
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
        insert cas;

       /*Insert new Case_Type__c Object*/
       Case_Type__c Ctc = new Case_Type__c();
       Ctc.Level_1__c = 'Test Level 1';
       Ctc.Level_2__c = 'Test Level 2';
       Ctc.Level_3__c = 'Test Level 3';
       Ctc.Case__c = cas.id;
       insert Ctc;
      
     
        ERT_Case_Type__c obj=new ERT_Case_Type__c();
        string one='one';
        string two='two';
        string three='three';
       string oldlevel1='OLDone';
       string oldlevel2='OLDtwo';
       string oldlevel3='OLDthree';
       string guid = 'a3k2F000-0007-7JiA-a3k2-000007JiAQAU';
        test.startTest();
        String testing=ERT_MultiLevelSelectEdit.savecasetype(one,two,three,oldlevel1,oldlevel2,oldlevel3,guid,cas.id);
        test.stopTest();
        system.assertEquals('successfull', testing);
    }
    
 public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public string strERTGuid{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
        
    } 
    
    

}

Here is Apex class
 
public class ERT_MultiLevelSelectEdit {
    @AuraEnabled
    public static List<LevelWrapper> getLevel1(string recID){
        List<String> tempLst1 = new List<String>();
        list<LevelWrapper> lstWrap=new list<LevelWrapper>();
        
        list<ERT_Case_Type__c>  lstertcase=new list<ERT_Case_Type__c>();
        lstertcase=[select id,UniqueGUID__c,Level_1__c,Level_2__c,Level_3__c from ERT_Case_Type__c where id=:recID];
        string strL1,strL2,strL3,strGuid;
        if(lstertcase.size()>0){
            strL1=lstertcase[0].Level_1__c;
            strL2=lstertcase[0].Level_2__c;
            strL3=lstertcase[0].Level_3__c;
            strGuid=lstertcase[0].UniqueGUID__c;
        }
       
       LevelWrapper guidObj= new LevelWrapper();
       string strERTGuid1=(string)strGuid;
       guidObj.strLevelType='recGUID';
       guidObj.strERTGuid=strERTGuid1;
       lstWrap.add(guidObj);
        
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c]) {
            LevelWrapper obj= new LevelWrapper();
            string strLev1=(string)ar.get('Level_1__c');
            obj.strLevelType='recL1';
            obj.strL1val=strLev1;
            if(strLev1==strL1)
                obj.isSelected=true;
            else
                obj.isSelected=false; 
            lstWrap.add(obj);
            
        }

        for(string ar:getLevel2(strL1)){
            if(strL1!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL2';
                obj.strL2val=strLev2;
                if(strLev2==strL2)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        
        for(string ar:getLevel3(strL1,strL2)){
            if(strL2!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL3';
                obj.strL3val=strLev2;
                if(strLev2==strL3)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        System.debug(' wrapper '+lstWrap);
        return lstWrap;
        
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
        List<String> tempLst2 = new List<String>();
        for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
        {
            tempLst2.add(''+ar.get('Level_2__c'));
        }
        
        return tempLst2;
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
        List<String> tempLst3 = new List<String>();
        for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
        {
            tempLst3.add(''+ar.get('Level_3__c'));
        }
        
        return tempLst3;
        
        
    } 
    
    @AuraEnabled
    public  static String  savecasetype(string level1,string level2,string level3,string oldlevel1,string oldlevel2,string oldlevel3,string guid,string id){
        string strMsg='successfull';
        try{
            ERT_Case_Type__c obj=new ERT_Case_Type__c();
            
            System.debug('CASE  = '+ Obj.Case__c); 
            Obj.Level_1__c=level1;
            System.debug('Level1  = '+ Obj.Level_1__c); 
            Obj.Level_2__c=level2;
            System.debug('Level2  = '+ Obj.Level_2__c); 
            Obj.Level_3__c=level3;
            System.debug('Level3  = '+ Obj.Level_3__c);
 
            if(id.startsWithIgnoreCase('500'))
                Obj.Case__c = id;
            
            else
                obj.id=id;
              upsert  Obj;
            if(oldlevel1 != ''){
            List<Case_Type__c> lstCTD = new List<Case_Type__c>();
            lstCTD=[SELECT id,Level_1__c,Level_2__c,Level_3__c  FROM Case_Type__c WHERE Level_1__c=:oldlevel1 AND Level_2__c=:oldlevel2 
                    AND Level_3__c=:oldlevel3 AND ERTUniqueGUID__c=:guid ];

           

                
            System.debug('Case Type existing data  = '+ lstCTD);
            lstCTD[0].Level_1__c=Obj.Level_1__c;
            
            lstCTD[0].Level_2__c=Obj.Level_2__c;
            
            lstCTD[0].Level_3__c=Obj.Level_3__c;
                
                upsert  lstCTD;
            
          }
            
        
            
        }
        
        catch(Exception ex){
            strMsg='error';
        }
        return strMsg;  
    }
    
    public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public string strERTGuid{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    
    
 }

Your help is needed and aappreciated

Fiona


 
Hi Pals,

My code is showing Red for Upsert statement,can someone help me in completing Test apex class write up for Upsert statments below
@isTest
public class ERT_MultiLevelSelectEditTest {
  
  @testSetup static void setup() {
        
    Case_Type_Data__c ct = new Case_Type_Data__c();
    ct.Level_1__c = 'Test Level 1';
    ct.Level_2__c = 'Test Level 2';
    ct.Level_3__c = 'Test Level 3';
    insert ct; 

    }
    
  @isTest
   static  void testGetLevel1()
   {
    
    Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
    insert cas;
    ERT_Case_Type__c  obj = new ERT_Case_Type__c ();
    obj.Level_1__c = 'Test Level 1';
    obj.Level_2__c = 'Test Level 2';
    obj.Level_3__c = 'Test Level 3';
    obj.Case__c = cas.id;
    upsert obj;
       
   test.startTest();
   List<ERT_MultiLevelSelectEdit.LevelWrapper> lstWrapper= ERT_MultiLevelSelectEdit.getLevel1(obj.id);
   test.stopTest();
   system.assertEquals('Test Level 1', lstWrapper[0].strL1val);
     
   
     
    

   }

  @isTest
   static void testGetLevel2()
   {
   test.startTest();
   List<String> s = ERT_MultiLevelSelectEdit.getLevel2('Test Level 1');
   test.stopTest();
   system.assertEquals('Test Level 2', s[0]);
      
   

   }
    
  @isTest
   static void testGetLevel3()
   {
    test.startTest();
    List<String> s = ERT_MultiLevelSelectEdit.getLevel3('Test Level 1','Test Level 2');
    test.stopTest();
    system.assertEquals('Test Level 3', s[0]);
   }
    
  @isTest 
   static  void testsaveCaseType(){
   
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
        insert cas;
       
        ERT_Case_Type__c obj=new ERT_Case_Type__c();
        string one='one';
        string two='two';
        string three='three';
        test.startTest();
        String testing=ERT_MultiLevelSelectEdit.savecasetype(one,two,three,cas.id);
        test.stopTest();
        system.assertEquals('successfull', testing);
    }
    
 public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    

}


Here is controller class
public class ERT_MultiLevelSelectEdit {
    @AuraEnabled
    public static List<LevelWrapper> getLevel1(string recID){
        List<String> tempLst1 = new List<String>();
        list<LevelWrapper> lstWrap=new list<LevelWrapper>();
        
        list<ERT_Case_Type__c>  lstertcase=new list<ERT_Case_Type__c>();
        lstertcase=[select id,Level_1__c,Level_2__c,Level_3__c from ERT_Case_Type__c where id=:recID];
        string strL1,strL2,strL3;
        if(lstertcase.size()>0){
            strL1=lstertcase[0].Level_1__c;
            strL2=lstertcase[0].Level_2__c;
            strL3=lstertcase[0].Level_3__c;
        }
        
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c]) {
            LevelWrapper obj= new LevelWrapper();
            string strLev1=(string)ar.get('Level_1__c');
            obj.strLevelType='recL1';
            obj.strL1val=strLev1;
            if(strLev1==strL1)
                obj.isSelected=true;
            else
                obj.isSelected=false; 
            lstWrap.add(obj);
            
        }

        for(string ar:getLevel2(strL1)){
            if(strL1!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL2';
                obj.strL2val=strLev2;
                if(strLev2==strL2)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        
        for(string ar:getLevel3(strL1,strL2)){
            if(strL2!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL3';
                obj.strL3val=strLev2;
                if(strLev2==strL3)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        System.debug(' wrapper '+lstWrap);
        return lstWrap;
        
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
        List<String> tempLst2 = new List<String>();
        for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
        {
            tempLst2.add(''+ar.get('Level_2__c'));
        }
        
        return tempLst2;
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
        List<String> tempLst3 = new List<String>();
        for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
        {
            tempLst3.add(''+ar.get('Level_3__c'));
        }
        
        return tempLst3;
        
        
    } 
    
    @AuraEnabled
    public  static String  savecasetype(string level1,string level2,string level3,string id){
        string strMsg='successfull';
        try{
            ERT_Case_Type__c obj=new ERT_Case_Type__c();
            
            System.debug('CASE  = '+ Obj.Case__c); 
            Obj.Level_1__c=level1;
            System.debug('Level1  = '+ Obj.Level_1__c); 
            Obj.Level_2__c=level2;
            System.debug('Level2  = '+ Obj.Level_2__c); 
            Obj.Level_3__c=level3;
            System.debug('Level3  = '+ Obj.Level_3__c);
            List<Case_Type__c> lstCTD = new List<Case_Type__c>();
            lstCTD=[select id,Level_1__c,Level_2__c,Level_3__c from Case_Type__c];
            
            lstCTD[0].Level_1__c=level1;
            
            lstCTD[0].Level_2__c=level2;
            
             lstCTD[0].Level_3__c=level3;
            if(id.startsWithIgnoreCase('500'))
                Obj.Case__c = id;
            
            else
                obj.id=id;
            upsert  obj;
              upsert  lstCTD;
            
          
            
          
            
        }
        
        catch(Exception ex){
            strMsg='error';
        }
        return strMsg;  
    }
    
    public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    
    
 }

It shows   Red for Upsert statements

User-added image


Thanks
Fiona
 
Dear Pals,

This is the question on including System.Assert statements on existing test class which has 93% code coverage for Apex controller class

Here is the test class,need your help in writing system.debug statments in the below class
 
@isTest
public class ERT_MultiLevelSelectEditTest {
    
  @testSetup static void setup() {
        
    Case_Type_Data__c ct = new Case_Type_Data__c();
    ct.Level_1__c = 'Test Level 1';
    ct.Level_2__c = 'Test Level 2';
    ct.Level_3__c = 'Test Level 3';
    insert ct;      
    }
    
  @isTest
   static  void testGetLevel1()
   {
    
    Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
    insert cas;
    ERT_Case_Type__c  obj = new ERT_Case_Type__c ();
    obj.Level_1__c = 'Test Level 1';
    obj.Level_2__c = 'Test Level 2';
    obj.Level_3__c = 'Test Level 3';
    obj.Case__c = cas.id;
    upsert obj;
    ERT_MultiLevelSelectEdit.getLevel1(obj.id);
    
    

   }

  @isTest
   static void testGetLevel2()
   {

    List<String> s = ERT_MultiLevelSelectEdit.getLevel2('Test Level 1');

   }
    
  @isTest
   static void testGetLevel3()
   {

    List<String> s = ERT_MultiLevelSelectEdit.getLevel3('Test Level 1','Test Level 2');

   }
    
  @isTest 
   static  void testsaveCaseType(){
   
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
        insert cas;
       
        ERT_Case_Type__c obj=new ERT_Case_Type__c();
        string one='one';
        string two='two';
        string three='three';
        test.startTest();
        String testing=ERT_MultiLevelSelectEdit.savecasetype(one,two,three,cas.id);
        test.stopTest();
    }
    

    

}

Here is controller class
 
public class ERT_MultiLevelSelectEdit {
    @AuraEnabled
    public static List<LevelWrapper> getLevel1(string recID){
        List<String> tempLst1 = new List<String>();
        list<LevelWrapper> lstWrap=new list<LevelWrapper>();
        
        list<ERT_Case_Type__c>  lstertcase=new list<ERT_Case_Type__c>();
        lstertcase=[select id,Level_1__c,Level_2__c,Level_3__c from ERT_Case_Type__c where id=:recID];
        string strL1,strL2,strL3;
        if(lstertcase.size()>0){
            strL1=lstertcase[0].Level_1__c;
            strL2=lstertcase[0].Level_2__c;
            strL3=lstertcase[0].Level_3__c;
        }
        
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c]) {
            LevelWrapper obj= new LevelWrapper();
            string strLev1=(string)ar.get('Level_1__c');
            obj.strLevelType='recL1';
            obj.strL1val=strLev1;
            if(strLev1==strL1)
                obj.isSelected=true;
            else
                obj.isSelected=false; 
            lstWrap.add(obj);
            
        }

        for(string ar:getLevel2(strL1)){
            if(strL1!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL2';
                obj.strL2val=strLev2;
                if(strLev2==strL2)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        
        for(string ar:getLevel3(strL1,strL2)){
            if(strL2!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL3';
                obj.strL3val=strLev2;
                if(strLev2==strL3)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        System.debug(' wrapper '+lstWrap);
        return lstWrap;
        
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
        List<String> tempLst2 = new List<String>();
        for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
        {
            tempLst2.add(''+ar.get('Level_2__c'));
        }
        
        return tempLst2;
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
        List<String> tempLst3 = new List<String>();
        for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
        {
            tempLst3.add(''+ar.get('Level_3__c'));
        }
        
        return tempLst3;
        
        
    } 
    
    @AuraEnabled
    public  static String  savecasetype(string level1,string level2,string level3,string id){
        string strMsg='successfull';
        try{
            ERT_Case_Type__c obj=new ERT_Case_Type__c();
            
            System.debug('CASE  = '+ Obj.Case__c); 
            Obj.Level_1__c=level1;
            System.debug('Level1  = '+ Obj.Level_1__c); 
            Obj.Level_2__c=level2;
            System.debug('Level2  = '+ Obj.Level_2__c); 
            Obj.Level_3__c=level3;
            System.debug('Level3  = '+ Obj.Level_3__c);
            if(id.startsWithIgnoreCase('500'))
                Obj.Case__c = id;
            else
                obj.id=id;
            upsert  obj;
            
        }
        
        catch(Exception ex){
            strMsg='error';
        }
        return strMsg;  
    }
    
    public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    
    
 }

Regards
Fiona
Hi Gurus,
have writtern the apex aura enabled controller for controller and also the test class,please help me in fixing and writing detailed test class for below upsert apex class

apex controller
public class PickListHandler {
   @AuraEnabled
   public static List<LavelWrapper> getLevel1(string recID){
       List<String> tempLst1 = new List<String>();
       list<LavelWrapper> lstWrap=new list<LavelWrapper>();
       //  System.debug('recid'+recID);
       list<ERT_Case_Type__c>  lstertcase=new list<ERT_Case_Type__c>();
       lstertcase=[select id,Level_1__c,Level_2__c,Level_3__c from ERT_Case_Type__c where id=:recID];//fetch data based on it
       string strL1,strL2,strL3;
       if(lstertcase.size()>0){
           strL1=lstertcase[0].Level_1__c;
           strL2=lstertcase[0].Level_2__c;
           strL3=lstertcase[0].Level_3__c;
       }
       //  System.debug(strL2+'recid'+strL1);
       for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c]) {
           LavelWrapper obj= new LavelWrapper();
           string strLav1=(string)ar.get('Level_1__c');
           obj.strLavelType='recL1';
           obj.strL1val=strLav1;
           if(strLav1==strL1)
               obj.isSelected=true;
           else
               obj.isSelected=false; 
           lstWrap.add(obj);
           //tempLst1.add(strLav1);
       }
       //get l2 data
       for(string ar:getLevel2(strL1)){
           if(strL1!=null){
               LavelWrapper obj= new LavelWrapper();
               // string strLav2=(string)ar.get('Level_2__c');
               string strLav2=(string)ar;
               obj.strLavelType='recL2';
               obj.strL2val=strLav2;
               if(strLav2==strL2)
                   obj.isSelected=true;
               else
                   obj.isSelected=false; 
               lstWrap.add(obj);
           }
       }
       //get l2 data
       for(string ar:getLevel3(strL1,strL2)){
           if(strL2!=null){
               LavelWrapper obj= new LavelWrapper();
               // string strLav2=(string)ar.get('Level_2__c');
               string strLav2=(string)ar;
               obj.strLavelType='recL3';
               obj.strL3val=strLav2;
               if(strLav2==strL3)
                   obj.isSelected=true;
               else
                   obj.isSelected=false; 
               lstWrap.add(obj);
           }
       }
       System.debug(' wrapper '+lstWrap);
       return lstWrap;
       
       
   } 
   
   @AuraEnabled
   public static List<String> getLevel2(string strName){
       List<String> tempLst2 = new List<String>();
       for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
       {
           tempLst2.add(''+ar.get('Level_2__c'));
       }
       
       return tempLst2;
       
   } 
   
   @AuraEnabled
   public static List<String> getLevel3(string strName1,string strName2){
       List<String> tempLst3 = new List<String>();
       for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
       {
           tempLst3.add(''+ar.get('Level_3__c'));
       }
       
       return tempLst3;
       
       
   } 
   
   @AuraEnabled
   public  static String  savecasetype(string level1,string level2,string level3,string id){
       string strMsg='successfull';
       try{
           ERT_Case_Type__c obj=new ERT_Case_Type__c();
           
           System.debug('CASE  = '+ Obj.Case__c); 
           Obj.Level_1__c=level1;
           System.debug('Level1  = '+ Obj.Level_1__c); 
           Obj.Level_2__c=level2;
           System.debug('Level2  = '+ Obj.Level_2__c); 
           Obj.Level_3__c=level3;
           System.debug('Level3  = '+ Obj.Level_3__c);
           if(id.startsWithIgnoreCase('500'))
               Obj.Case__c = id;
           else
               obj.id=id;
           upsert  obj;
           
       }
       
       catch(Exception ex){
           strMsg='error';
       }
       return strMsg;  
   }
   
   public class LavelWrapper{
       @AuraEnabled
       public string strLavelType{get;set;}
       @AuraEnabled
       public string strL1val{get;set;}
       @AuraEnabled
       public string strL2val{get;set;}
       @AuraEnabled
       public string strL3val{get;set;}
       @AuraEnabled
       public boolean isSelected{get;set;}
       
   }
   
   
   
}
Here is test class
@IsTest
public class testGetAllLevels { 

@IsTest
static  void testGetLevel1()
{
    Case_Type_Data__c obj = new Case_Type_Data__c();
    obj.Level_1__c = 'Test Level 1';
    insert obj;
    List<String> s = PickListHandler.getLevel1();

}

@IsTest
static void testGetLevel2()
{
    Case_Type_Data__c obj = new Case_Type_Data__c();
    obj.Level_1__c = 'Test Level 1';
    insert obj;
    List<String> s = PickListHandler.getLevel2('Test Level 1');

}
    
@IsTest
static void testGetLevel3()
{
    Case_Type_Data__c obj = new Case_Type_Data__c();
    obj.Level_1__c = 'Test Level 1';
    obj.Level_2__c = 'Test Level 2';
    obj.Level_3__c = 'Test Level 3';
    insert obj;
    List<String> s = PickListHandler.getLevel3('Test Level 1','Test Level 2');

}
    
@IsTest 
static  void testsaveCaseType(){
        // Create the Case Record.
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
        insert cas;
       
        ERT_Case_Type__c obj=new ERT_Case_Type__c();
        string one='one';
        string two='two';
        string three='three';
        test.startTest();
        String testing=PickListHandler.savecasetype(one,two,three,cas.id);
        test.stopTest();
    }
    

    
 
    
}

Here is error while running test class
== Test Summary
NAME                 VALUE                                
───────────────────  ─────────────────────────────────────
Outcome              Failed                               
Tests Ran            1                                    
Pass Rate            0%                                   
Fail Rate            100%                                 
Skip Rate            0%                                   
Test Run Id          7072F00001g7Xqs                      
Test Execution Time  null ms     

=== Test Results
TEST NAME                   OUTCOME      MESSAGE                                                                                                           RUNTIME (MS)
──────────────────────────  ───────────  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────  ────────────
testGetAllLevels.<compile>  CompileFail  line 10, column 38: Method does not exist or incorrect signature: void getLevel1() from the type PickListHandler  null

Your help is needed and appreciated

Fiona
 
Hi Gurus,
For some requirment ,i cannot use lightning-record-edit-form ,hence i am using lightning-combobox to get the field values from Apex controller and displaying in LWC component..Controller Looks like this
 
public with sharing class ERT_MultiLevelSelectEdit {
  
    @AuraEnabled(cacheable=true)
public static list<ERT_Case_Type__c> getExistingERTLevels(String ERTId)
{
  
  return [Select Id, Level_1__c,Level_2__c,Level_3__c from ERT_Case_Type__c WHERE Id =:ERTId];
}
    
}

App html is 
<template>
    <lightning-card title="ERT Case Edit- Lightning Web Component" icon-name="custom:custom63">
        <lightning-combobox
            name="Level_1__c"
            label="Level 1"
            placeholder="Choose Level 1 To Edit"
            value={value}
            onchange={handleChange}
            options={statusOptions}>
        </lightning-combobox>
        
    </lightning-card>
</template>

And app JS is below
import { LightningElement, api, wire, track } from 'lwc';

import getExistingERTLevels from '@salesforce/apex/ERT_MultiLevelSelectEdit.getExistingERTLevels';
let i=0;

export default class ERT_MultiLevelSelectEditLWC extends LightningElement {
     /** Id of record to display. */
    @api recordId; //this captures ERTId which is passed from Parent Component
    @track error;   //this holds errors

    @track items = []; //this holds the array for records with value & label

    @track value = '';  //this displays selected value of combo box

    /* Load ERT records based on ERT Record Id from Controller */
    @wire(getExistingERTLevels, { ERTId: '$recordId'})
    wiredERTLevels({ error, data }) {
        if (data) {
            for(i=0; i<data.length; i++) {
                console.log('id=' + data[i].Id);
                this.items = [...this.items ,{value: data[i].Id , label: data[i].Level_1__c,label: data[i].Level_2__c,label: data[i].Level_3__c}];                                   
            }                
            this.error = undefined;
        } else if (error) {
            this.error = error;
            this.contacts = undefined;
        }
    }
   
    //getter property from statusOptions which return the items array
    get statusOptions() {
        console.log(this.items);
        return this.items;
    }

    handleChange(event) {
        // Get the string of the "value" attribute on the selected option
        const selectedOption = event.detail.value;
        console.log('selectedOption=' + selectedOption);

        //This is for event propagation
        
        const filterChangeEvent = new CustomEvent('filterchange', {
            detail: { selectedOption },
        });

        
        // Fire the custom event
        this.dispatchEvent(filterChangeEvent);
    }
    
}

Please help me how do i write a logic to save the record successfully Back to Controller

Regards,
Fiona
Hi Gurus,

I am trying to edit an existing ERT case type which is a child to Case object by overriding standard EDIT buttin in ERT case record ,here is error 

User-added imageI am using use Philippe Ozil's ready component (https://github.com/pozil/sfdc-ui-lookup) for the lookup/autocomplete thing. copied save LookupSearchResult class, the whole aura component and 2 aura events in my org ..here is controller apex
public with sharing class ERT_MultiLevelSelectEdit {
    @AuraEnabled(cacheable=true)
    public static List<LookupSearchResult> search(String searchTerm, List<String> selectedIds){
        if(String.isBlank(searchTerm) || searchTerm.length() < 2){
            return null;
        }
        String t = '%' + searchTerm + '%'; 
        
        List<Case_Type_Data__c> records =  [FIND :('*' + searchTerm + '*') IN ALL FIELDS 
        RETURNING Case_Type_Data__c(Id, Name, Level_1__c, Level_2__c, Level_3__c)][0];
        
     
        
        List<LookupSearchResult> results = new List<LookupSearchResult>();
        for(Case_Type_Data__c ctd : records){
            results.add(new LookupSearchResult(ctd.Id, 'Case_Type_Data__c', 'standard:case_wrap_up', ctd.Name,
                String.join(new List<String>{ctd.Level_1__c , ctd.Level_2__c, ctd.Level_3__c}, '; ')
            ));
        }
        return results;
    } 
}

Here is cmp
<aura:component implements="force:hasRecordId,force:appHostable,flexipage:availableForAllPageTypes,force:lightningQuickAction,lightning:actionOverride" access="global" controller="ERT_MultiLevelSelectEdit">
        
    <aura:attribute access="public" type="List" name="selection" default="[]"/>
    <aura:attribute access="public" type="List" name="errors" default="[]"/>

    <lightning:card title="Edit Case Type">

        <lightning:recordEditForm aura:id="myForm" objectApiName="ERT_Case_Type__c" onsubmit="{!c.onSubmit}" onsuccess="{!c.onSuccess}">
        <lightning:messages />
        <c:Lookup selection="{!v.selection}" onSearch="{!c.lookupSearch}" onSelection="{!c.useSelected}" errors="{!v.errors}" label="Search" placeholder="Search Case Types Data"/>
        <lightning:inputField aura:id="Level_1__c" fieldName="Level_1__c" />
        <lightning:inputField aura:id="Level_2__c" fieldName="Level_2__c" />
        <lightning:inputField aura:id="Level_3__c" fieldName="Level_3__c" />
        <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="save" label="Save" />
    </lightning:recordEditForm>
    </lightning:card>
</aura:component>

Any resolution why I am getting this Case: id value of incorrect type: a3k2F0000007GUpQAMerror ""

Regards,
Fiona
 
Hi Gurus,

this is an apex controller code to insert a record,please help me in writing a code to load an existing record and modify it as well
 
public class PickListHandler {
    @AuraEnabled
    public static List<String> getLevel1(){
    List<String> tempLst1 = new List<String>();
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c])
    {
        tempLst1.add(''+ar.get('Level_1__c'));
    }

    return tempLst1;
      
      
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
    List<String> tempLst2 = new List<String>();
       for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
    {
       tempLst2.add(''+ar.get('Level_2__c'));
    }

    return tempLst2;
      
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
     List<String> tempLst3 = new List<String>();
      for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
    {
       tempLst3.add(''+ar.get('Level_3__c'));
    }

    return tempLst3;
      
      
    } 
         
     @AuraEnabled
     public  static String  savecasetype(string level1,string level2,string level3,string id){
     string strMsg='successfull';
          try{
     ERT_Case_Type__c obj=new ERT_Case_Type__c();
     Obj.Case__c = id;
     System.debug('CASE  = '+ Obj.Case__c); 
     Obj.Level_1__c=level1;
     System.debug('Level1  = '+ Obj.Level_1__c); 
     Obj.Level_2__c=level2;
     System.debug('Level2  = '+ Obj.Level_2__c); 
     Obj.Level_3__c=level3;
     System.debug('Level3  = '+ Obj.Level_3__c); 
     Insert obj;
  
     }
     
    catch(Exception ex){
            strMsg='error';
        }
     return strMsg;  
}
    
     
    
    

}

Your help is highly appreciated

Regards,
Fiona
Current Behaviour of my Lightning component:- Lightning component is used on Case Type to create multi levels Level1 then Dependent Level2 then dependent Level3 selected and clicking in Save saves entire Record to Case,works fine till here on one of custom object Case Type
User-added image
Expected behavior:- Now I want to extend the functionality of above lightning component so that user who wishes to change Record data on Case can just update the value of Level1, Level2 and Level3 and do an Upsert on the same case
Now to achieve Edit a record functionality,added lightning:actionOverride in apex cmp and then overridden the standard Edit button of ERT case type custom object with the Lightning component as below
User-added image
Here comes the problem when I use the same component in Edit button

User-added image
Then select levels

User-added imageI see error as below

User-added imageNow my question is what changes is needed in the below Apex controller or Lightning Component Bundle to successfully update the previously saved Level1, Level2, Level3 on the Case

Here is Apex controller
 
public class PickListHandler {
                            @AuraEnabled
                            public static List<String> getLevel1(){
                            List<String> tempLst1 = new List<String>();
                                for(AggregateResult  ar : [select Level_1__c,COUNT(id) from 
                            Case_Type_Data__c  group by Level_1__c])
                            {
                                tempLst1.add(''+ar.get('Level_1__c'));
                            }

                            return tempLst1;
                              
                              
                            } 
                            
                            @AuraEnabled
                            public static List<String> getLevel2(string strName){
                            List<String> tempLst2 = new List<String>();
                               for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
                            {
                               tempLst2.add(''+ar.get('Level_2__c'));
                            }

                            return tempLst2;
                              
                            } 
                            
                            @AuraEnabled
                            public static List<String> getLevel3(string strName1,string strName2){
                             List<String> tempLst3 = new List<String>();
                              for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
                            {
                               tempLst3.add(''+ar.get('Level_3__c'));
                            }

                            return tempLst3;
                              
                              
                            } 
                                 
                             @AuraEnabled
                             public  static String  savecasetype(string level1,string level2,string level3,string id){
                             string strMsg='successfull';
                                  try{
                             ERT_Case_Type__c obj=new ERT_Case_Type__c();
                             Obj.Case__c = id;
                             System.debug('CASE  = '+ Obj.Case__c); 
                             Obj.Level_1__c=level1;
                             System.debug('Level1  = '+ Obj.Level_1__c); 
                             Obj.Level_2__c=level2;
                             System.debug('Level2  = '+ Obj.Level_2__c); 
                             Obj.Level_3__c=level3;
                             System.debug('Level3  = '+ Obj.Level_3__c); 
                             Insert obj;
                          
                             }
                             
                            catch(Exception ex){
                                    strMsg='error';
                                }
                             return strMsg;  
                        }
                            
                             
                            
                            

                        }

here is CMP file
 
<aura:component controller="PickListHandler" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:actionOverride" access="global" >
            <!-- Actions-->
            <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
            <aura:handler event="force:refreshView" action="{!c.isRefreshed}" />
          
            <!-- variable-->
            <aura:attribute name="lstLevel1" type="String[]" />
             <aura:attribute name="lstLevel2" type="String[]"  />
              <aura:attribute name="lstL3"  type="String[]"  />
                <aura:attribute name="firstlevel1selected" type="String" default="" />
             <aura:attribute name="secondlevelselected" type="String" default="" />
              <aura:attribute name="thirdlevelselected"  type="String" default="" />
            
               <div class="slds-container--center slds-container--small slds-m-top--small">
                <div class="slds-form--stacked">
                     
                    <lightning:select name="parentPicklist" label="Level 1"  aura:id="ddLevel1"  onchange="{!c.getLvl1}">
                        <option value="">--- None ---</option>
                        <aura:iteration items="{!v.lstLevel1}" var="item1">
                            <option  value="{!item1.value}" selected="{!item1.selected}" >{!item1}</option>
                        </aura:iteration>
                    </lightning:select>
                     
                    <lightning:select name="Level2Picklist" label="Level 2"  aura:id="ddLevel2"   onchange="{!c.getSelectedValue}" >
                        <option value="">--- None ---</option>
                        <aura:iteration items="{!v.lstLevel2}" var="item2">
                            <option  value="{!item2.value}" selected="{!item2.selected}" >{!item2}</option>
                        </aura:iteration>
                    </lightning:select>
                    
                     <lightning:select name="Level3Picklist" label="Level 3"  aura:id="ddLevel3" onchange="{!c.getlevel3}"  >
                        <option value="">--- None ---</option>
                        <aura:iteration items="{!v.lstL3}" var="item3">
                            <option  value="{!item3.value}" selected="{!item3.selected}" >{!item3}</option>
                        </aura:iteration>
                    </lightning:select>
                     
                </div>        
            </div>
           <lightning:button variant="brand" label="Save" onclick="{!c.onConfirm}" />
        </aura:component>
Your help is highly appreciated

Fiona
 
Hi Gurus,
 I have a case in which i want to override  standard Edit Button Call A Custom Lignting Component on Record Detail Page
  
  How do i do that?
User-added image
Your help is highly appreciated

Regards,
Fiona
Dear gurus,

Here is my batch code ,Now problem is even if it uses Database.Batchable still I am observing the below governor limit error as First error: Too many query rows: 50001 ,is there a way to write a test class which will prevent such occurrences before it actually happens,I found this error after I wrote below ```SOQL```

select id, ApexClass.Name, CompletedDate, CreatedBy.name, Status, ExtendedStatus from AsyncApexJob where CreatedDate = today order by CreatedDate desc
 
global class OnlineRequestAppointmentHandlingBatch implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.stateful   {
						global Set<Id> AptList = new Set<Id> ();
						public static final String STATUS_CANCELED    = 'Canceled';
						public static final String REASON_FOR_CANCEL    = 'Other (NOT Requested by Cust)';
						List<Event_Log__c> inputEventLogs = New List<Event_Log__c>();
						List<ServiceAppointment> ApptsToCancel = new List<ServiceAppointment>();
						public OnlineRequestAppointmentHandlingBatch(List<Event_Log__c> eventLogList){
							this.inputEventLogs = eventLogList;
						}
						
						global Database.QueryLocator start(Database.BatchableContext BC) {
							Set<String> strReqDetailIds =  new Set<String>();
							Set<Id> setStores 			= new Set<Id>();
							List<Store__c> storesList = new List<Store__c>();
							for(Event_Log__c elObj: inputEventLogs){
								strReqDetailIds.add(elObj.Event_Record_ID__c);
							}            
							for(Store_Request_Detail__c srdRec : [Select id, Store__c from Store_Request_Detail__c where id in :strReqDetailIds]){
								setStores.add(srdRec.Store__c);  
							}
							storesList = [select Id from Store__c where Id IN:setStores];
							
							AptList.addAll(TM_AppointmentCancellationHandler.AppointmentCancellation(storesList));
							//String query = 'select Id from Store__c where Id IN:setStores';
							String query = 'SELECT Id, status,reschedule__c,reason_for_cancel__c  FROM ServiceAppointment WHERE Id IN : AptList';
							return Database.getQueryLocator(query);
						}
						
						global void execute(Database.BatchableContext bc,List<ServiceAppointment> scope) {      
							{
								For (ServiceAppointment SA:scope)
								{
									SA.status               = STATUS_CANCELED;
									SA.reschedule__c        = false;
									SA.reason_for_cancel__c = TM_Util.check( REASON_FOR_CANCEL );
									ApptsToCancel.add(SA);
								}
								if(!ApptsToCancel.isEmpty()){
									TM_SendEmailAppointmentWrapper.AutoEmailCallout = false;
									Database.SaveResult[] srList = database.update(ApptsToCancel, false);
									system.debug('srList=='+srList);
								}
						}
						}
						
						global void finish(Database.BatchableContext BC) {
							system.debug('AptList=='+AptList);
							if(!AptList.isEmpty()){
								system.debug('CMT_CANCEL_APPOINTMENT_EMAILS_BATCH_SIZE::'+OnlineRequestService.CMT_CANCEL_APPOINTMENT_EMAILS_BATCH_SIZE);
								Database.executeBatch(new TM_CancelBlockStoreAppointmentEmails(AptList),OnlineRequestService.CMT_CANCEL_APPOINTMENT_EMAILS_BATCH_SIZE);
							}
						}
					}

Regards,
Fiona
Dear gurus,

This issue is with lightning:select saving previous values and not the existing ones..In the video (https://www.youtube.com/watch?v=dVxASPnXfGI&feature=youtu.be)   I will show problem...
  • First saved Level1 , Level2 and Level3 successfully then
  • Now,I reset Level1 and you can see Level2 and Level3 in the Aura component,as you see Aura component got successfully changed to "---None---" but when I saved the record, instead of saving "---None---" in Level2 and Level3 it saved the old values of Level2 and Level3 which is not expected, so it seems a rendering issue can someone help me in fixing this issue
Here is .cmp code
 
<aura:component controller="PickListHandler" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <!-- Actions-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  
    <!-- variable-->
    <aura:attribute name="lstLevel1" type="String[]" />
     <aura:attribute name="lstLevel2" type="String[]"  />
      <aura:attribute name="lstL3"  type="String[]"  />
        <aura:attribute name="firstlevel1selected" type="String" default="" />
     <aura:attribute name="secondlevelselected" type="String" default="" />
      <aura:attribute name="thirdlevelselected"  type="String" default="" />
    
	   <div class="slds-container--center slds-container--small slds-m-top--small">
        <div class="slds-form--stacked">
             
            <lightning:select name="parentPicklist" label="Level 1"  aura:id="ddLevel1"  onchange="{!c.getLvl1}">
                <option value="">--- None ---</option>
                <aura:iteration items="{!v.lstLevel1}" var="item1">
                    <option  value="{!item1.value}" selected="{!item1.selected}" >{!item1}</option>
                </aura:iteration>
            </lightning:select>
             
            <lightning:select name="Level2Picklist" label="Level 2"  aura:id="ddLevel2"   onchange="{!c.getSelectedValue}" >
                <option value="">--- None ---</option>
                <aura:iteration items="{!v.lstLevel2}" var="item2">
                    <option  value="{!item2.value}" selected="{!item2.selected}" >{!item2}</option>
                </aura:iteration>
            </lightning:select>
			
			 <lightning:select name="Level3Picklist" label="Level 3"  aura:id="ddLevel3" onchange="{!c.getlevel3}"  >
                <option value="">--- None ---</option>
                <aura:iteration items="{!v.lstL3}" var="item3">
                    <option  value="{!item3.value}" selected="{!item3.selected}" >{!item3}</option>
                </aura:iteration>
            </lightning:select>
             
        </div>        
    </div>
   <lightning:button variant="brand" label="Save" onclick="{!c.onConfirm}" />
</aura:component>
Here is controller JS code
 
({
  
    doInit : function(component, event, helper) {
        var action = component.get("c.getLevel1");
        action.setCallback(this, function(e) {
            if(e.getState()=='SUCCESS'){
                var result=e.getReturnValue();
                component.set("v.lstLevel1",result);
            }
        });
        $A.enqueueAction(action);
    },    
    getLvl1:function(component, event, helper){
       
        var picklist=component.find('ddLevel1');
        var picklistvalue=picklist.get('v.value');
        component.set("v.firstlevel1selected",picklistvalue);
        var action = component.get("c.getLevel2");
        action.setParams({  'strName' : picklistvalue  });
        action.setCallback(this, function(e) {
            if(e.getState()=='SUCCESS'){
                var result=e.getReturnValue();
                component.set("v.lstLevel2",result);
                helper.getSelectedValue(component,event,helper);
            }
        });
        $A.enqueueAction(action);
            },
    getSelectedValue:function(component, event, helper){
        var picklist=component.find('ddLevel1');
       
        var picklistvalue=picklist.get('v.value');
         
        var picklistdep=component.find('ddLevel2');
        
        var picklistvaluedep2=picklistdep.get('v.value');
        component.set("v.secondlevelselected",picklistvaluedep2);
        var action = component.get("c.getLevel3");
        
        action.setParams({  'strName1' : picklistvalue,
                         'strName2' : picklistvaluedep2});//
        action.setCallback(this, function(e) {
            if(e.getState()=='SUCCESS'){
                var result=e.getReturnValue();
                component.set("v.lstL3",result);
            }
        });
        $A.enqueueAction(action);
    },
    getlevel3:function(component, event, helper){
        var picklist=component.find('ddLevel3');
       
        var picklistvalue=picklist.get('v.value');
         component.set("v.thirdlevelselected",picklistvalue);
        
    },
    onConfirm:function(component, event, helper){
        var picklist=component.find('ddLevel1');
        var picklistvalue=picklist.get('v.value');
        var picklistdep=component.find('ddLevel2');
        var picklistvaluedep2=picklistdep.get('v.value');
       
        var picklistdep3=component.find('ddLevel3');
        var picklistvaluedep3=picklistdep3.get('v.value');
        console.log(component.get('v.firstlevel1selected'));
         console.log(component.get('v.secondlevelselected'));
         console.log(component.get('v.thirdlevelselected'));
        
        var action = component.get("c.savecasetype");
        
        action.setParams({  'level1' : picklistvalue,
                          'level2' : picklistvaluedep2,
                          'level3' : picklistvaluedep3,
                          'id' : component.get("v.recordId")});
                          
        
        var toastEvent = $A.get("e.force:showToast");
        action.setCallback(this, function(e) {
            if(e.getState()=='SUCCESS'){
                var result=e.getReturnValue();
                if(result==='successfull'){
                    toastEvent.setParams({
                        "title": "Success!",
                        "message": "The record has been inserted  successfully."
                    });
                    toastEvent.fire();
                }else{
                    toastEvent.setParams({
                        "title": "Error",
                        "message": "The record has not been inserted  successfully."
                    });
                    toastEvent.fire();
                }
            }
        });
        $A.enqueueAction(action);
       
    },
       
       
})
Here is Helper JS code
 
({
    getSelectedValue:function(component, event, helper){
       var picklist=component.find('ddLevel1');
      
       var picklistvalue=picklist.get('v.value');
        
       var picklistdep=component.find('ddLevel2');
       
       var picklistvaluedep2=picklistdep.get('v.value');
       component.set("v.secondlevelselected",picklistvaluedep2);
       var action = component.get("c.getLevel3");
       
       action.setParams({  'strName1' : picklistvalue,
                        'strName2' : picklistvaluedep2});//
       action.setCallback(this, function(e) {
           if(e.getState()=='SUCCESS'){
               var result=e.getReturnValue();
               component.set("v.lstL3",result);
           }
       });
       $A.enqueueAction(action);
   },
   getlevel3:function(component, event, helper){
       var picklist=component.find('ddLevel3');
      
       var picklistvalue=picklist.get('v.value');
        component.set("v.thirdlevelselected",picklistvalue);
       
   }
   ,
   resetlevel2:function(component, event, helper){
    component.set("v.lstLevel2", "--- None ---");
     
    
},
resetlevel3:function(component, event, helper){

    component.set("v.lstL3", "--- None ---");
   
}
})

Your help in fixing this is very much appreciated

Thanks,
Fiona

 
Hi Gurus,

I am trying to fetch dependent picklist values by referring 
https://sfdcmonkey.com/2018/08/31/dependent-picklist-lightningselect-lightning-salesforce/
 and 
https://developer.salesforce.com/forums/?id=9060G0000005pt3QAA

Here is problem as you see I see no drop down value in "Country" controlling field 

can some one please help ,in the blog they used contact standard object and here I have used custom object and its API name
which is ERT_Case_Type__c

here is my cmp file
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
                access="global"
                controller="dependentPicklist_UpdateCtrl">
    <!-- call doInit function on component load -->  
    <aura:handler name="init" value="this" action="{!c.doInit}"/>
    
    <!-- aura attributes-->  
    <aura:attribute name="listControllingValues" type="list" default="[]" description="to store controller field values"/>
    <aura:attribute name="listDependingValues" type="list" default="['--- None ---']" description="to store dependent field values"/>
    <aura:attribute name="listSubDependingValues" type="list" default="['--- None ---']" description="to store dependent field values"/>
    
    <aura:attribute name="depnedentFieldMap" type="map" description="map to store dependent values with controlling value"/>
    <aura:attribute name="subDepnedentFieldMap" type="map" description="map to store sub dependent values with controlling value"/>
    <aura:attribute name="bDisabledDependentFld" type="boolean" default="true"/> 
    <aura:attribute name="bDisabledSubDependentFld" type="boolean" default="true"/> 
    
    
    <aura:attribute name="objDetail" type="ERT_Case_Type__c" default="{'sobjectType' : 'ERT_Case_Type__c'}"/>
    <aura:attribute name="controllingFieldAPI" type="string" default="Level_1__c" description="store field API name of Controller field"/>
    <aura:attribute name="dependingFieldAPI" type="string" default="Level_2__c" description="store field API name of dependent field"/>
    <aura:attribute name="subDependingFieldAPI" type="string" default="Level_3__c" description="store field API name of sub dependent field"/>
    
    <!--Controller Field-->
    <lightning:layoutItem size="12" padding="around-small">    
        <lightning:select name="controllerFld"
                          value="{!v.objDetail.Level_1__c}"
                          label="Country"
                          onchange="{!c.onControllerFieldChange}">
            <aura:iteration items="{!v.listControllingValues}" var="val">
                <option value="{!val}">{!val}</option>
            </aura:iteration>
        </lightning:select>
    </lightning:layoutItem>
    
    <!--Dependent Field-->
    <lightning:layoutItem size="12" padding="around-small">
        <lightning:select name="dependentFld"
                          value="{!v.objDetail.Level_2__c}"
                          label="City"
                          disabled="{!v.bDisabledDependentFld}"
                          onchange="{!c.onSubControllerFieldChange}">
            <aura:iteration items="{!v.listDependingValues}" var="val">
                <option value="{!val}">{!val}</option>
            </aura:iteration>
        </lightning:select>
    </lightning:layoutItem>
    
    <!--sub Dependent Field-->
    <lightning:layoutItem size="12" padding="around-small">
        <lightning:select name="subDependentFld"
                          value="{!v.objDetail.Level_3__c}"
                          label="language"
                          disabled="{!v.bDisabledSubDependentFld}">
            <aura:iteration items="{!v.listSubDependingValues}" var="val">
                <option value="{!val}">{!val}</option>
            </aura:iteration>
        </lightning:select>
    </lightning:layoutItem>
    
</aura:component>
Your help is highly appreciated

Regards,
Fiona

 
Hi Gurus

Do we write  test method for  email notification sending as part of batch,in here at below finish stage there is code for email sending ,so question is do I need to write test class for email sending functionality as we?? if yes,any ideas how to write a class for below?
global class leadUpdateBatch implements Database.batchable<sobject>,Database.stateful{
    public Map<id,id> newLeadTaskIdMap = new map<id,id>();
    public Map<id,Task> taskMap = new Map<id,Task>();
    
    String VIP1 = Label.B2C_VIP_API_User;
    String VIP2 = Label.B2C_VIP_AAL_API_User;
    String VIP3 = Label.B2C_VIP_SWITCH_API_User;
    
    Id VIPInboundTaskId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('VIP Inbound').getRecordTypeId();
    Id VIPOutboundTaskId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('VIP Outbound').getRecordTypeId();
    Id OutBoundCallingTaskId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Outbound Call').getRecordTypeId();
    Id CDTaskId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('ILC Task').getRecordTypeId();   
    global List<String> errorMessages = new List<String>();
    Global List<String> failedRecIdList =new List<String>();
    global Set<String> faliedIdSet=new Set<String>();
    public DateTime dt = Datetime.now().addMinutes(-integer.valueof(Label.LeadUpdateBatchInterval));
    String dispo = NULL;
    String LEAD = 'Lead';    
    
    
	Map<string,string> taskLeadFieldMap=new Map<string,string>
		{'Call_Type__c'=>'Call_Type__c', 'Disposition__c'=>'Disposition__c',
		'FollowUpLastmodified__c'=>'PilotTaskFollowup__c', 'Reason_for_Call__c'=>'Reason_for_Call__c',
		'Customer_Budget__c'=>'Customer_Budget__c', 
		'Time_Frame_for_Purchase__c'=>'Time_Frame_for_Purchase__c','TOM_Order_Number__c'=>'TOM_Order__c',
		'Chat_Engagement_Id__c'=>'Chat_Engagement_Id__c','New_Device__c'=>'Device__c',
		'Current_Carrier__c'=>'Current_Carrier__c','Current_Monthly_Bill__c'=>'Monthly_Bill__c',
		'Lines__c'=>'Lines__c', 'Savings__c'=>'Savings__c', 'Customer_Type__c'=>'Customer_Type__c',
		'T_Mobile_ID__c'=>'T_Mobile_ID__c','Customer_Contact_Phone_Number__c'=>'Phone',
		'Zip_Code__c'=>'Zip__c', 'Follow_Up_Date_Time__c'=>'Follow_Up_Date_Time__c',
		'First_Call_Attempt_Date__c'=>'First_Call_Attempt_Date__c', 
		'Second_Call_Attempt_Date__c'=>'Second_Call_Attempt__c',
        'Agent_Manager_Role__c'=>'Dispositioned_Agent_parent_role__c',
        'Agent_Name__c'=>'Dispositoned_Agent_Name__c'};
		
    global Database.QueryLocator start(Database.BatchableContext bc){

        
        return Database.getQueryLocator('Select Id,whoid,Call_Type__c,Agent_Name__c,Agent_Manager_Role__c,FollowUpLastmodified__c,disposition__c,Follow_up_Date_Time__c,Reason_for_Call__c,Customer_Budget__c,Time_Frame_for_Purchase__c,TOM_Order_Number__c,Chat_Engagement_ID__c,New_Device__c,Current_Carrier__c,Current_Monthly_Bill__c,Lines__c,Savings__c,Customer_Type__c,T_Mobile_ID__c,Customer_Contact_Phone_Number__c,Zip_Code__c,First_Call_Attempt_Date__c,Second_Call_Attempt_Date__c,RecordTypeId  from task where LastModifiedDate >=:dt and WHO.Type =: Lead and OwnerId !=:VIP1 and OwnerId !=:VIP2 and OwnerId !=:VIP3 and disposition__c !=:dispo and (RecordTypeId =:VIPInboundTaskId or RecordTypeId =:CDTaskId or RecordTypeId =:VIPOutboundTaskId or RecordTypeId =:OutBoundCallingTaskId) ORDER BY LastModifiedDate DESC');
        //return Database.getQueryLocator('Select Id,whoid,Call_Type__c,FollowUpLastmodified__c,disposition__c,Follow_up_Date_Time__c,Reason_for_Call__c,Customer_Budget__c,Time_Frame_for_Purchase__c,TOM_Order_Number__c,Chat_Engagement_ID__c,New_Device__c,Current_Carrier__c,Current_Monthly_Bill__c,Lines__c,Savings__c,Customer_Type__c,T_Mobile_ID__c,Customer_Contact_Phone_Number__c,Zip_Code__c,First_Call_Attempt_Date__c,Second_Call_Attempt_Date__c,RecordTypeId  from task where LastModifiedDate >=:dt and whoid in (select id from Lead) and OwnerId !=:VIP1 and OwnerId !=:VIP2 and OwnerId !=:VIP3 and (RecordTypeId =:VIPInboundTaskId or RecordTypeId =:CDTaskId or RecordTypeId =:VIPOutboundTaskId ) ORDER BY LastModifiedDate DESC');
        
    }
    
    global void execute(Database.BatchableContext bc,List<Task> scope){ 
        
        for(task task : scope){                       
            if(!newLeadTaskIdMap.containsKey(task.whoId)){
            	newLeadTaskIdMap.put(task.whoId,task.id);              
            }
			taskMap.put(task.id,task);
        }
		
        if(!newLeadTaskIdMap.isEmpty()){
            List<Lead> updateLeads=new List<Lead>();
            Boolean hasChanged=false;
            List<Lead> leadList = [select id,
                                   			Call_Type__c,Disposition__c,PilotTaskFollowup__c,
                                   			Reason_for_Call__c,Dispositioned_Agent_parent_role__c,Dispositoned_Agent_Name__c,Customer_Budget__c,Time_Frame_for_Purchase__c,
                                   			TOM_Order__c,Chat_Engagement_Id__c,Device__c,Current_Carrier__c,
                                   			Monthly_Bill__c,Lines__c,Savings__c,Customer_Type__c,T_Mobile_ID__c,
                                   			Phone,Zip__c,Follow_Up_Date_Time__c,First_Call_Attempt_Date__c,Second_Call_Attempt__c
                                   			from Lead where id IN:newLeadTaskIdMap.keySet()];
			
            for(Lead lead : leadList)
			{
                //faliedIdSet.add(ld.Id);
                Task taskRecord = taskMap.get(newLeadTaskIdMap.get(lead.id));
                hasChanged=false;
				for(string taskField:taskLeadFieldMap.keyset())
				{
                    System.debug('==taskRecord.get(taskField)=='+taskRecord.get(taskField));
                    System.debug('==lead.get(taskLeadFieldMap.get(taskField))=='+lead.get(taskLeadFieldMap.get(taskField)));
					if(taskRecord.get(taskField)!=NULL && taskRecord.get(taskField) != lead.get(taskLeadFieldMap.get(taskField)))
                    {                        
                        System.debug('==taskLeadFieldMap.get(taskField)=='+taskLeadFieldMap.get(taskField));                        
						lead.put(taskLeadFieldMap.get(taskField), taskRecord.get(taskField));
						hasChanged=true;
					}					
				}
                if(hasChanged)
					updateLeads.add(lead);
			}
				
            if(!updateLeads.isEmpty() ){
                System.debug('updateLeads==='+updateLeads);
                
                Database.SaveResult[] srList = database.update(updateLeads, false);
                System.debug('===srList==='+srList);
				String errMsg;
                // Iterate through each returned result
                for (Database.SaveResult sr : srList){
					errMsg='';
                    if (!sr.isSuccess()) {
                        System.debug('Successfully  ' + sr.getId());
                        faliedIdSet.add(sr.getId());
						// Operation failed, so get all errors                
                        for(Database.Error err : sr.getErrors()) {                                             
                            System.debug(err.getStatusCode() + ': ' + err.getMessage());  
                            errMsg+= '-'+ err.getMessage();                     
						}
						failedRecIdList.add(errMsg);
                    }
                }
            }
            
        } 
    }
    
    
    global void finish(Database.BatchableContext bc){
        
        
        AsyncApexJob a = [SELECT Id,Status,JobType,NumberOfErrors,JobItemsProcessed,TotalJobItems,CompletedDate,ExtendedStatus
        FROM AsyncApexJob WHERE Id =:BC.getJobId()];
        
        //Get the list of Emails from Custom setting and send notification   
        Email_Notifications__c emaillist = Email_Notifications__c.getValues('LeadUpdateBatchEmails');
        System.debug('emaillist ==== > '+emaillist);
        List<String> userList = emaillist.Email_Address__c.split(',');
          
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        
        mail.setToAddresses(userList);
        mail.setSubject('LeadUpdateBatch Status - ' + a.Status);
        mail.setSaveAsActivity(false);
        //mail.setPlainTextBody('Failed Records Ids: ' +faliedIdSet);
        //mail.setPlainTextBody('Error Message : ' +failedRecIdList);
        mail.setPlainTextBody('Failed Record Details:    ' +faliedIdSet+failedRecIdList + '\n' + 'Job Completed Date :    ' + a.CompletedDate + '\n' + 'Job Status :      ' + a.Status + '\n'+ 'Total Job Items processed :      ' + a.TotalJobItems + '\n'+ 'Number of Job Items processed :       ' + a.JobItemsProcessed + '\n' + 'Number of Failures :       '+ a.NumberOfErrors );
        //+ '\n' + 'Number of Error Messages ' + errorMessages.size() + '\n' +'Error Message' + String.join(errorMessages, '\n'));
        
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
  
   
}

 
Dear gurus,
I would like to know if you can provide me test class for For Task Update and Email Send to Leads in Batch..here is the batch code for the same
 
global class leadUpdateBatch implements Database.batchable<sobject>,Database.stateful{
    public Map<id,id> newLeadTaskIdMap = new map<id,id>();
    public Map<id,Task> taskMap = new Map<id,Task>();
    
    String VIP1 = Label.B2C_VIP_API_User;
    String VIP2 = Label.B2C_VIP_AAL_API_User;
    String VIP3 = Label.B2C_VIP_SWITCH_API_User;
    
    Id VIPInboundTaskId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('VIP Inbound').getRecordTypeId();
    Id VIPOutboundTaskId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('VIP Outbound').getRecordTypeId();
    Id OutBoundCallingTaskId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Outbound Call').getRecordTypeId();
    Id CDTaskId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('ILC Task').getRecordTypeId();   
    global List<String> errorMessages = new List<String>();
    Global List<String> failedRecIdList =new List<String>();
    global Set<String> faliedIdSet=new Set<String>();
    public DateTime dt = Datetime.now().addMinutes(-integer.valueof(Label.LeadUpdateBatchInterval));
    String dispo = NULL;
    String LEAD = 'Lead';    
    
    
	Map<string,string> taskLeadFieldMap=new Map<string,string>
		{'Call_Type__c'=>'Call_Type__c', 'Disposition__c'=>'Disposition__c',
		'FollowUpLastmodified__c'=>'PilotTaskFollowup__c', 'Reason_for_Call__c'=>'Reason_for_Call__c',
		'Customer_Budget__c'=>'Customer_Budget__c', 
		'Time_Frame_for_Purchase__c'=>'Time_Frame_for_Purchase__c','TOM_Order_Number__c'=>'TOM_Order__c',
		'Chat_Engagement_Id__c'=>'Chat_Engagement_Id__c','New_Device__c'=>'Device__c',
		'Current_Carrier__c'=>'Current_Carrier__c','Current_Monthly_Bill__c'=>'Monthly_Bill__c',
		'Lines__c'=>'Lines__c', 'Savings__c'=>'Savings__c', 'Customer_Type__c'=>'Customer_Type__c',
		'T_Mobile_ID__c'=>'T_Mobile_ID__c','Customer_Contact_Phone_Number__c'=>'Phone',
		'Zip_Code__c'=>'Zip__c', 'Follow_Up_Date_Time__c'=>'Follow_Up_Date_Time__c',
		'First_Call_Attempt_Date__c'=>'First_Call_Attempt_Date__c', 
		'Second_Call_Attempt_Date__c'=>'Second_Call_Attempt__c',
        'Agent_Manager_Role__c'=>'Dispositioned_Agent_parent_role__c',
        'Agent_Name__c'=>'Dispositoned_Agent_Name__c'};
		
    global Database.QueryLocator start(Database.BatchableContext bc){

        
        return Database.getQueryLocator('Select Id,whoid,Call_Type__c,Agent_Name__c,Agent_Manager_Role__c,FollowUpLastmodified__c,disposition__c,Follow_up_Date_Time__c,Reason_for_Call__c,Customer_Budget__c,Time_Frame_for_Purchase__c,TOM_Order_Number__c,Chat_Engagement_ID__c,New_Device__c,Current_Carrier__c,Current_Monthly_Bill__c,Lines__c,Savings__c,Customer_Type__c,T_Mobile_ID__c,Customer_Contact_Phone_Number__c,Zip_Code__c,First_Call_Attempt_Date__c,Second_Call_Attempt_Date__c,RecordTypeId  from task where LastModifiedDate >=:dt and WHO.Type =: Lead and OwnerId !=:VIP1 and OwnerId !=:VIP2 and OwnerId !=:VIP3 and disposition__c !=:dispo and (RecordTypeId =:VIPInboundTaskId or RecordTypeId =:CDTaskId or RecordTypeId =:VIPOutboundTaskId or RecordTypeId =:OutBoundCallingTaskId) ORDER BY LastModifiedDate DESC');
        //return Database.getQueryLocator('Select Id,whoid,Call_Type__c,FollowUpLastmodified__c,disposition__c,Follow_up_Date_Time__c,Reason_for_Call__c,Customer_Budget__c,Time_Frame_for_Purchase__c,TOM_Order_Number__c,Chat_Engagement_ID__c,New_Device__c,Current_Carrier__c,Current_Monthly_Bill__c,Lines__c,Savings__c,Customer_Type__c,T_Mobile_ID__c,Customer_Contact_Phone_Number__c,Zip_Code__c,First_Call_Attempt_Date__c,Second_Call_Attempt_Date__c,RecordTypeId  from task where LastModifiedDate >=:dt and whoid in (select id from Lead) and OwnerId !=:VIP1 and OwnerId !=:VIP2 and OwnerId !=:VIP3 and (RecordTypeId =:VIPInboundTaskId or RecordTypeId =:CDTaskId or RecordTypeId =:VIPOutboundTaskId ) ORDER BY LastModifiedDate DESC');
        
    }
    
    global void execute(Database.BatchableContext bc,List<Task> scope){ 
        
        for(task task : scope){                       
            if(!newLeadTaskIdMap.containsKey(task.whoId)){
            	newLeadTaskIdMap.put(task.whoId,task.id);              
            }
			taskMap.put(task.id,task);
        }
		
        if(!newLeadTaskIdMap.isEmpty()){
            List<Lead> updateLeads=new List<Lead>();
            Boolean hasChanged=false;
            List<Lead> leadList = [select id,
                                   			Call_Type__c,Disposition__c,PilotTaskFollowup__c,
                                   			Reason_for_Call__c,Dispositioned_Agent_parent_role__c,Dispositoned_Agent_Name__c,Customer_Budget__c,Time_Frame_for_Purchase__c,
                                   			TOM_Order__c,Chat_Engagement_Id__c,Device__c,Current_Carrier__c,
                                   			Monthly_Bill__c,Lines__c,Savings__c,Customer_Type__c,T_Mobile_ID__c,
                                   			Phone,Zip__c,Follow_Up_Date_Time__c,First_Call_Attempt_Date__c,Second_Call_Attempt__c
                                   			from Lead where id IN:newLeadTaskIdMap.keySet()];
			
            for(Lead lead : leadList)
			{
                //faliedIdSet.add(ld.Id);
                Task taskRecord = taskMap.get(newLeadTaskIdMap.get(lead.id));
                hasChanged=false;
				for(string taskField:taskLeadFieldMap.keyset())
				{
                    System.debug('==taskRecord.get(taskField)=='+taskRecord.get(taskField));
                    System.debug('==lead.get(taskLeadFieldMap.get(taskField))=='+lead.get(taskLeadFieldMap.get(taskField)));
					if(taskRecord.get(taskField)!=NULL && taskRecord.get(taskField) != lead.get(taskLeadFieldMap.get(taskField)))
                    {                        
                        System.debug('==taskLeadFieldMap.get(taskField)=='+taskLeadFieldMap.get(taskField));                        
						lead.put(taskLeadFieldMap.get(taskField), taskRecord.get(taskField));
						hasChanged=true;
					}					
				}
                if(hasChanged)
					updateLeads.add(lead);
			}
				
            if(!updateLeads.isEmpty() ){
                System.debug('updateLeads==='+updateLeads);
                
                Database.SaveResult[] srList = database.update(updateLeads, false);
                System.debug('===srList==='+srList);
				String errMsg;
                // Iterate through each returned result
                for (Database.SaveResult sr : srList){
					errMsg='';
                    if (!sr.isSuccess()) {
                        System.debug('Successfully  ' + sr.getId());
                        faliedIdSet.add(sr.getId());
						// Operation failed, so get all errors                
                        for(Database.Error err : sr.getErrors()) {                                             
                            System.debug(err.getStatusCode() + ': ' + err.getMessage());  
                            errMsg+= '-'+ err.getMessage();                     
						}
						failedRecIdList.add(errMsg);
                    }
                }
            }
            
        } 
    }
    
    
    global void finish(Database.BatchableContext bc){
        
        
        AsyncApexJob a = [SELECT Id,Status,JobType,NumberOfErrors,JobItemsProcessed,TotalJobItems,CompletedDate,ExtendedStatus
        FROM AsyncApexJob WHERE Id =:BC.getJobId()];
        
        //Get the list of Emails from Custom setting and send notification   
        Email_Notifications__c emaillist = Email_Notifications__c.getValues('LeadUpdateBatchEmails');
        System.debug('emaillist ==== > '+emaillist);
        List<String> userList = emaillist.Email_Address__c.split(',');
          
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        
        mail.setToAddresses(userList);
        mail.setSubject('LeadUpdateBatch Status - ' + a.Status);
        mail.setSaveAsActivity(false);
        //mail.setPlainTextBody('Failed Records Ids: ' +faliedIdSet);
        //mail.setPlainTextBody('Error Message : ' +failedRecIdList);
        mail.setPlainTextBody('Failed Record Details:    ' +faliedIdSet+failedRecIdList + '\n' + 'Job Completed Date :    ' + a.CompletedDate + '\n' + 'Job Status :      ' + a.Status + '\n'+ 'Total Job Items processed :      ' + a.TotalJobItems + '\n'+ 'Number of Job Items processed :       ' + a.JobItemsProcessed + '\n' + 'Number of Failures :       '+ a.NumberOfErrors );
        //+ '\n' + 'Number of Error Messages ' + errorMessages.size() + '\n' +'Error Message' + String.join(errorMessages, '\n'));
        
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
  
   
}

Your help is highly appreciated

Regards
Fiona
Dear Pals,

I need to  Fire ShowNavigateToList After ShowToast On Single Save Function Of JS file,somehow only ShowToast working and not the ShowNavigateToList,Here is  what i have written for Save button,basically after the record is Upserted i want the page to move to ListView,what change is needed below
 
onConfirm:function(component, event, helper){
        var picklist=component.find('ddLevel1');
        var picklistvalue=picklist.get('v.value');
        var picklistdep=component.find('ddLevel2');
        var picklistvaluedep2=picklistdep.get('v.value');
        var picklistoldL1=component.get('v.oldL1');
        var picklistoldL2=component.get('v.oldL2');
        var picklistoldL3=component.get('v.oldL3');
        var ertrecordGuid=component.get('v.ertGUID');
        var picklistdep3=component.find('ddLevel3');
        var picklistvaluedep3=picklistdep3.get('v.value');
        var action = component.get("c.savecasetype");
       
        action.setParams({  'level1' : picklistvalue,
                          'level2' : component.get('v.secondlevelselected'),
                          'level3' : picklistvaluedep3,
                          'oldlevel1' : picklistoldL1,
                          'oldlevel2' : picklistoldL2,
                          'oldlevel3' : picklistoldL3,
                          'guid':ertrecordGuid,
                          'id' : component.get("v.recordId")});
        
        
        var toastEvent = $A.get("e.force:showToast");
        action.setCallback(this, function(e) {
            if(e.getState()=='SUCCESS'){
                var result=e.getReturnValue();
                        
                
                if(result==='successfull'){
                    toastEvent.setParams({
                        "title": "Success!",
                        "message": "The record has been Upserted  successfully."
                         
                    });
                    
                    toastEvent.fire();
                   
                }else{
                   
                    toastEvent.setParams({
                        "title": "Error",
                        "message": "The record has not been Upserted  successfully."
                    });
                    toastEvent.fire();
                }
            }
            
            
          
             $A.get('e.force:refreshView').fire(); 
             
        });
        
           var action = component.get("c.getListViews");
    action.setCallback(this, function(response){
        var state = response.getState();
        if (state === "SUCCESS") {
            var listviews = response.getReturnValue();
            var navEvent = $A.get("e.force:navigateToList");
            navEvent.setParams({
                "listViewId": listviews.Id,
                "listViewName": null,
                "scope": "Case"
            });
            navEvent.fire();
        }
    });
        $A.enqueueAction(action);
        
          
        
    }

Here is ListView controller
 
@AuraEnabled 

public static List<ListView> getListViews() { 

    List<ListView> listviews = 

        [SELECT Id, Name FROM ListView WHERE SobjectType = 'Case' and Name='Recently Viewed Cases']; 

  

   

    return listviews; 

}



Your help is needed and appreciated
Regards,
Fiona​​​​​​​

 
Hi Pals,

My code is showing Red for Upsert statement,can someone help me in completing Test apex class write up for Upsert statments below
@isTest
public class ERT_MultiLevelSelectEditTest {
  
  @testSetup static void setup() {
        
    Case_Type_Data__c ct = new Case_Type_Data__c();
    ct.Level_1__c = 'Test Level 1';
    ct.Level_2__c = 'Test Level 2';
    ct.Level_3__c = 'Test Level 3';
    insert ct; 

    }
    
  @isTest
   static  void testGetLevel1()
   {
    
    Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
    insert cas;
    ERT_Case_Type__c  obj = new ERT_Case_Type__c ();
    obj.Level_1__c = 'Test Level 1';
    obj.Level_2__c = 'Test Level 2';
    obj.Level_3__c = 'Test Level 3';
    obj.Case__c = cas.id;
    upsert obj;
       
   test.startTest();
   List<ERT_MultiLevelSelectEdit.LevelWrapper> lstWrapper= ERT_MultiLevelSelectEdit.getLevel1(obj.id);
   test.stopTest();
   system.assertEquals('Test Level 1', lstWrapper[0].strL1val);
     
   
     
    

   }

  @isTest
   static void testGetLevel2()
   {
   test.startTest();
   List<String> s = ERT_MultiLevelSelectEdit.getLevel2('Test Level 1');
   test.stopTest();
   system.assertEquals('Test Level 2', s[0]);
      
   

   }
    
  @isTest
   static void testGetLevel3()
   {
    test.startTest();
    List<String> s = ERT_MultiLevelSelectEdit.getLevel3('Test Level 1','Test Level 2');
    test.stopTest();
    system.assertEquals('Test Level 3', s[0]);
   }
    
  @isTest 
   static  void testsaveCaseType(){
   
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
        insert cas;
       
        ERT_Case_Type__c obj=new ERT_Case_Type__c();
        string one='one';
        string two='two';
        string three='three';
        test.startTest();
        String testing=ERT_MultiLevelSelectEdit.savecasetype(one,two,three,cas.id);
        test.stopTest();
        system.assertEquals('successfull', testing);
    }
    
 public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    

}


Here is controller class
public class ERT_MultiLevelSelectEdit {
    @AuraEnabled
    public static List<LevelWrapper> getLevel1(string recID){
        List<String> tempLst1 = new List<String>();
        list<LevelWrapper> lstWrap=new list<LevelWrapper>();
        
        list<ERT_Case_Type__c>  lstertcase=new list<ERT_Case_Type__c>();
        lstertcase=[select id,Level_1__c,Level_2__c,Level_3__c from ERT_Case_Type__c where id=:recID];
        string strL1,strL2,strL3;
        if(lstertcase.size()>0){
            strL1=lstertcase[0].Level_1__c;
            strL2=lstertcase[0].Level_2__c;
            strL3=lstertcase[0].Level_3__c;
        }
        
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c]) {
            LevelWrapper obj= new LevelWrapper();
            string strLev1=(string)ar.get('Level_1__c');
            obj.strLevelType='recL1';
            obj.strL1val=strLev1;
            if(strLev1==strL1)
                obj.isSelected=true;
            else
                obj.isSelected=false; 
            lstWrap.add(obj);
            
        }

        for(string ar:getLevel2(strL1)){
            if(strL1!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL2';
                obj.strL2val=strLev2;
                if(strLev2==strL2)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        
        for(string ar:getLevel3(strL1,strL2)){
            if(strL2!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL3';
                obj.strL3val=strLev2;
                if(strLev2==strL3)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        System.debug(' wrapper '+lstWrap);
        return lstWrap;
        
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
        List<String> tempLst2 = new List<String>();
        for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
        {
            tempLst2.add(''+ar.get('Level_2__c'));
        }
        
        return tempLst2;
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
        List<String> tempLst3 = new List<String>();
        for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
        {
            tempLst3.add(''+ar.get('Level_3__c'));
        }
        
        return tempLst3;
        
        
    } 
    
    @AuraEnabled
    public  static String  savecasetype(string level1,string level2,string level3,string id){
        string strMsg='successfull';
        try{
            ERT_Case_Type__c obj=new ERT_Case_Type__c();
            
            System.debug('CASE  = '+ Obj.Case__c); 
            Obj.Level_1__c=level1;
            System.debug('Level1  = '+ Obj.Level_1__c); 
            Obj.Level_2__c=level2;
            System.debug('Level2  = '+ Obj.Level_2__c); 
            Obj.Level_3__c=level3;
            System.debug('Level3  = '+ Obj.Level_3__c);
            List<Case_Type__c> lstCTD = new List<Case_Type__c>();
            lstCTD=[select id,Level_1__c,Level_2__c,Level_3__c from Case_Type__c];
            
            lstCTD[0].Level_1__c=level1;
            
            lstCTD[0].Level_2__c=level2;
            
             lstCTD[0].Level_3__c=level3;
            if(id.startsWithIgnoreCase('500'))
                Obj.Case__c = id;
            
            else
                obj.id=id;
            upsert  obj;
              upsert  lstCTD;
            
          
            
          
            
        }
        
        catch(Exception ex){
            strMsg='error';
        }
        return strMsg;  
    }
    
    public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    
    
 }

It shows   Red for Upsert statements

User-added image


Thanks
Fiona
 
Hi Gurus,

this is an apex controller code to insert a record,please help me in writing a code to load an existing record and modify it as well
 
public class PickListHandler {
    @AuraEnabled
    public static List<String> getLevel1(){
    List<String> tempLst1 = new List<String>();
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c])
    {
        tempLst1.add(''+ar.get('Level_1__c'));
    }

    return tempLst1;
      
      
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
    List<String> tempLst2 = new List<String>();
       for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
    {
       tempLst2.add(''+ar.get('Level_2__c'));
    }

    return tempLst2;
      
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
     List<String> tempLst3 = new List<String>();
      for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
    {
       tempLst3.add(''+ar.get('Level_3__c'));
    }

    return tempLst3;
      
      
    } 
         
     @AuraEnabled
     public  static String  savecasetype(string level1,string level2,string level3,string id){
     string strMsg='successfull';
          try{
     ERT_Case_Type__c obj=new ERT_Case_Type__c();
     Obj.Case__c = id;
     System.debug('CASE  = '+ Obj.Case__c); 
     Obj.Level_1__c=level1;
     System.debug('Level1  = '+ Obj.Level_1__c); 
     Obj.Level_2__c=level2;
     System.debug('Level2  = '+ Obj.Level_2__c); 
     Obj.Level_3__c=level3;
     System.debug('Level3  = '+ Obj.Level_3__c); 
     Insert obj;
  
     }
     
    catch(Exception ex){
            strMsg='error';
        }
     return strMsg;  
}
    
     
    
    

}

Your help is highly appreciated

Regards,
Fiona
Hi Gurus,

I am trying to fetch dependent picklist values by referring 
https://sfdcmonkey.com/2018/08/31/dependent-picklist-lightningselect-lightning-salesforce/
 and 
https://developer.salesforce.com/forums/?id=9060G0000005pt3QAA

Here is problem as you see I see no drop down value in "Country" controlling field 

can some one please help ,in the blog they used contact standard object and here I have used custom object and its API name
which is ERT_Case_Type__c

here is my cmp file
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
                access="global"
                controller="dependentPicklist_UpdateCtrl">
    <!-- call doInit function on component load -->  
    <aura:handler name="init" value="this" action="{!c.doInit}"/>
    
    <!-- aura attributes-->  
    <aura:attribute name="listControllingValues" type="list" default="[]" description="to store controller field values"/>
    <aura:attribute name="listDependingValues" type="list" default="['--- None ---']" description="to store dependent field values"/>
    <aura:attribute name="listSubDependingValues" type="list" default="['--- None ---']" description="to store dependent field values"/>
    
    <aura:attribute name="depnedentFieldMap" type="map" description="map to store dependent values with controlling value"/>
    <aura:attribute name="subDepnedentFieldMap" type="map" description="map to store sub dependent values with controlling value"/>
    <aura:attribute name="bDisabledDependentFld" type="boolean" default="true"/> 
    <aura:attribute name="bDisabledSubDependentFld" type="boolean" default="true"/> 
    
    
    <aura:attribute name="objDetail" type="ERT_Case_Type__c" default="{'sobjectType' : 'ERT_Case_Type__c'}"/>
    <aura:attribute name="controllingFieldAPI" type="string" default="Level_1__c" description="store field API name of Controller field"/>
    <aura:attribute name="dependingFieldAPI" type="string" default="Level_2__c" description="store field API name of dependent field"/>
    <aura:attribute name="subDependingFieldAPI" type="string" default="Level_3__c" description="store field API name of sub dependent field"/>
    
    <!--Controller Field-->
    <lightning:layoutItem size="12" padding="around-small">    
        <lightning:select name="controllerFld"
                          value="{!v.objDetail.Level_1__c}"
                          label="Country"
                          onchange="{!c.onControllerFieldChange}">
            <aura:iteration items="{!v.listControllingValues}" var="val">
                <option value="{!val}">{!val}</option>
            </aura:iteration>
        </lightning:select>
    </lightning:layoutItem>
    
    <!--Dependent Field-->
    <lightning:layoutItem size="12" padding="around-small">
        <lightning:select name="dependentFld"
                          value="{!v.objDetail.Level_2__c}"
                          label="City"
                          disabled="{!v.bDisabledDependentFld}"
                          onchange="{!c.onSubControllerFieldChange}">
            <aura:iteration items="{!v.listDependingValues}" var="val">
                <option value="{!val}">{!val}</option>
            </aura:iteration>
        </lightning:select>
    </lightning:layoutItem>
    
    <!--sub Dependent Field-->
    <lightning:layoutItem size="12" padding="around-small">
        <lightning:select name="subDependentFld"
                          value="{!v.objDetail.Level_3__c}"
                          label="language"
                          disabled="{!v.bDisabledSubDependentFld}">
            <aura:iteration items="{!v.listSubDependingValues}" var="val">
                <option value="{!val}">{!val}</option>
            </aura:iteration>
        </lightning:select>
    </lightning:layoutItem>
    
</aura:component>
Your help is highly appreciated

Regards,
Fiona

 
Hi Gurus,

Step1--> I have a scenario where, in my dependent picklist, first i am setting values for  picklist Level2 and then selected dependent picklist value in Level3
User-added image

Step2--> Now this time removed selection at Level2 ,automatically Level3 selection also got erased and 

User-added image

Step3--> Click Save

User-added image

Here is problem,that value selected in Step2 getting saved rather than the reset value in step3

I have added code to reset values at 
ui:inputSelectOption
but it seems the reset  values from lightning components are not getting reset and saved rather cached values are getting saved after I click save,

Please help in fixing the code, here is the component code
<aura:component controller="PickListHandler" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
					<!-- Actions-->
					<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
					<aura:handler name="change" value="{!v.pageReference}"
								  action="{!c.onPageReferenceChanged}" />
					<!-- variable-->
					<aura:attribute name="lstLevel1" type="String[]" />
					 <aura:attribute name="lstLevel2" type="String[]" />
					  <aura:attribute name="lstL3" type="String[]" />
					<span> Level 1</span>
					<ui:inputSelect aura:id="ddLevel1" change="{!c.getLvl1}">
						<ui:inputSelectOption label="-Select-" value="true"/>        
						<aura:iteration items="{!v.lstLevel1}" var="value">          
							<ui:inputSelectOption label="{!value}" text="{!value}" />
						</aura:iteration>
					</ui:inputSelect>
					<span>Level 2</span>
					<ui:inputSelect aura:id="ddLevel2"  change="{!c.getSelectedValue}">
						 <ui:inputSelectOption label="-Select-" value="{!v.clrlv1}"/>        
						<aura:iteration items="{!v.lstLevel2}" var="value">          
							<ui:inputSelectOption label="{!value}" text="{!value}" />
						</aura:iteration>
					</ui:inputSelect>
					 <span>Level 3</span>
					<ui:inputSelect aura:id="ddLevel3" >
						<ui:inputSelectOption label="-Select-" value="{!v.clrlv2}"/>        
						<aura:iteration items="{!v.lstL3}" var="value">          
							<ui:inputSelectOption label="{!value}" text="{!value}" />
						</aura:iteration>
					</ui:inputSelect>
				   <lightning:button variant="brand" label="Save" onclick="{!c.onConfirm}" />
				</aura:component>

here is controller  code
({
					   reset1 : function(component, event, helper) {
							component.set("v.clrlvl", "");
						},
						reset2 : function(component, event, helper) {
							component.set("v.clrlv2", "");
						},onPageReferenceChanged: function(cmp, event, helper) {
							$A.get('e.force:refreshView').fire();
						},
						doInit : function(component, event, helper) {
							var action = component.get("c.getLevel1");
							action.setCallback(this, function(e) {
								if(e.getState()=='SUCCESS'){
									var result=e.getReturnValue();
									component.set("v.lstLevel1",result);
								}
							});
							$A.enqueueAction(action);
						},    
						getLvl1:function(component, event, helper){
						   
							var picklist=component.find('ddLevel1');
							var picklistvalue=picklist.get('v.value');
							var action = component.get("c.getLevel2");
							action.setParams({  'strName' : picklistvalue  });
							action.setCallback(this, function(e) {
								if(e.getState()=='SUCCESS'){
									var result=e.getReturnValue();
									component.set("v.lstLevel2",result);
								}
							});
							$A.enqueueAction(action);
								},
						getSelectedValue:function(component, event, helper){
							var picklist=component.find('ddLevel1');
							var picklistvalue=picklist.get('v.value');
							var picklistdep=component.find('ddLevel2');
							var picklistvaluedep2=picklistdep.get('v.value');
							var action = component.get("c.getLevel3");
							action.setParams({  'strName1' : picklistvalue,
											 'strName2' : picklistvaluedep2});//
							action.setCallback(this, function(e) {
								if(e.getState()=='SUCCESS'){
									var result=e.getReturnValue();
									component.set("v.lstL3",result);
								}
							});
							$A.enqueueAction(action);
						},
						onConfirm:function(component, event, helper){
							var picklist=component.find('ddLevel1');
							var picklistvalue=picklist.get('v.value');
							var picklistdep=component.find('ddLevel2');
							var picklistvaluedep2=picklistdep.get('v.value');
						   
							var picklistdep3=component.find('ddLevel3');
							var picklistvaluedep3=picklistdep3.get('v.value');
							var action = component.get("c.savecasetype");
							
							action.setParams({  'level1' : picklistvalue,
											  'level2' : picklistvaluedep2,
											  'level3' : picklistvaluedep3,
											  'id' : component.get("v.recordId")});
											  
							
							var toastEvent = $A.get("e.force:showToast");
							action.setCallback(this, function(e) {
								if(e.getState()=='SUCCESS'){
									var result=e.getReturnValue();
									if(result==='successfull'){
										toastEvent.setParams({
											"title": "Success!",
											"message": "The record has been inserted  successfully."
										});
										toastEvent.fire();
									}else{
										toastEvent.setParams({
											"title": "Error",
											"message": "The record has not been inserted  successfully."
										});
										toastEvent.fire();
									}
								}
							});
							$A.enqueueAction(action);
						   
						}
					})

Your help is highy appreciated

Regards,
Fiona

 
Dear gurus,

I would like to know if there is possibility of writing a SOQL similar like we do in SQL
like Distinct of Level_1__c,Level_2__c and Level_3__c

Currently SOQL is 
    
select Case__c, Level_1__c, Level_2__c,Level_3__c  FROM ERT_Case_Type__c



How to rewrite to include Distinct of Level_1__c,Level_2__c and Level_3__c

Thanks & Regards,
Fiona
Hi Gurus,

Need a Test class for Batchable class with database.insert function then saves the results and iterate through each results 
 
global void execute(Database.BatchableContext BC, List<ERT_Case_Type__c> exeList) {
						
						// process each batch of records
						List<Case_Type__c> listCTD = new List<Case_Type__c>();
						System.debug('ERT Case No is =====>' +exeList);
						for(ERT_Case_Type__c exe : exeList)
						{        
							listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c));
							// System.debug('ERT Case No is =====>' +Case__c);
						}

						System.debug('ERT Case No is =====>' +listCTD);
						insert listCTD;
						
						
						Database.SaveResult[] srList = Database.insert(listCTD, false);
						
						// Iterate through each returned result
						for (Database.SaveResult sr : srList) {
							if (sr.isSuccess()) {
								// Operation was successful, so get the ID of the record that was processed
								System.debug('Successfully inserted Case_Type__c: ' + sr.getId());
							}
							else {
								// Operation failed, so get all errors                
								for(Database.Error err : sr.getErrors()) {
									System.debug('The following error has occurred.');                    
									System.debug(err.getStatusCode() + ': ' + err.getMessage());
									System.debug('Case_Type__c fields that affected this error: ' + err.getFields());
								}
							}
						}            
						
					}   
					
					global void finish(Database.BatchableContext BC) {
						// execute any post-processing operations
					}
				}

 
Dear gurus,

I have custom object1 named Case_Type_Data__c with Level_1__c, Level_2__c,Level_3__c
and i have another custom object2 named  ERT_Case_Type__c with same fields Level_1__c, Level_2__c,Level_3__c

A batch copied data from ERT_Case_Type__c to Case_Type_Data__c

Now i try to write SOQL in workbench to find out which records didnt get copied
 
Select Level_1__c,Level_2__c,Level_3__c From Case_Type_Data__c Where Level_3__c NOT IN (Select Level_3__c From ERT_Case_Type__c)

Workbench throws error
MALFORMED_QUERY: semi join sub selects can only query id fields, cannot use: 'Level_3__c'
Please note Id of ERT_Case_Type__c and Id of Case_Type_Data__c doesnt matches hence cant use Id

Please provide me a Join SOQL to get records which didn't got copied from ERT_Case_Type__c to Case_Type_Data__c
Regards
Fiona
 
Hi Gurus,
I need to build out a solution to create a search field on the new Case Type Data object in all 3 of the Level fields and populate based on selection.

Similar to SF Global Search I  would like to type 2-3 characters in the text search field and it would find the matching text in the Level1-3 fields and when selected the Level 1-3 field would populate.

What do I need to do to achieve thisUser-added image
Regards,
Fiona
Hi ,

Please help in writing a test class for below Schedulable class
 
global class CopyERTBatchDaily implements Schedulable {
  global void execute(SchedulableContext sc) {
//  batchable b = new batchable(); 
      // your batch class
  CopyERTBatch bbb= new copyertbatch();
  database.executebatch(bbb);
  }
}

Regards
Fiona
Dear gurus,

How do i setup this batch job to execute at 6am PST Mon tuesday wed thursday
 
global class CopyExecutive_RTBatch implements Database.Batchable<sObject> {
  
    global Database.QueryLocator start(Database.BatchableContext BC) {
        // collect the batches of records or objects to be passed to execute
        
        String query = 'select Case__c, Level_1__c, Level_2__c,Level_3__c  FROM Executive_RT_Case_Type__c';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Executive_RT_Case_Type__c> exeList) {
       
        // process each batch of records
List<Case_Type__c> listCTD = new List<Case_Type__c>();
        
        for(Executive_RT_Case_Type__c exe : exeList)
        {        
           	listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c));
            //System.debug('Executive_RT Case No is =====>' +Case__c);
        }
        try {
        	
            insExecutive_RT listCTD;
        
        } catch(Exception e) {
            System.debug(e);
        }
        
    }   
    
    global void finish(Database.BatchableContext BC) {
    	// execute any post-processing operations
  }
}

Thanks,
Fiona

 
Hi Gurus,

Please help me in writng a test class for scheduled batch apex below ,i want 100% code coverage please
 
global class ERTExtract255BatchClass implements Database.Batchable<sObject>, Database.Stateful {
    global Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator(
            'SELECT ID,Description,Case_Desc_255__c FROM Case' 
        );
    }
    global void execute(Database.BatchableContext bc, List<Case> scope){
        // process each batch of record
        List<Case> lstCase = new List<Case>();       
        for (Case cas : scope) {
            cas.Case_Desc_255__c = cas.Description.Left(255);
            lstCase.add(cas);  
        }   
        update lstCase;
    }   
    global void finish(Database.BatchableContext bc){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
       
    
      AsyncApexJob a = [Select a.TotalJobItems, a.Status, a.NumberOfErrors,
      a.JobType, a.JobItemsProcessed, a.ExtendedStatus, a.CreatedById,
      a.CompletedDate From AsyncApexJob a WHERE id = :BC.getJobId()];
       
      // below code will send an email to User about the status
      String[] email = new String[]{'.com'};
      mail.setToAddresses(email);
      mail.setReplyTo('abc@gmail.com'); 
      mail.setSenderDisplayName('ERT Extract First 255 Char Batch Processing');
      mail.setSubject('Batch Processing '+a.Status);
      mail.setPlainTextBody('The Batch Apex job processed '+ a.TotalJobItems+'batches with '+a.NumberOfErrors+'failures '+'Job Item processed are '+a.JobItemsProcessed);
      Messaging.sendEmail(new Messaging.Singleemailmessage [] {mail});
    }   
     
}

Thanks,
Fiona​​​​​​​



 
i have created a Junction object as below
User-added image

But when I type below query I don't see data why?
select Id from Case_ERT_Junc__c
User-added image
Dear Friends,
Need a help in writing Batch Job that takes the first 255 characters from the existing long description field and  populates it into the new description field

Basically a batch job to copy first 255 characters from Case_Desc and update it to Case_Desc_255__c

Your help is highly appreciated

Regards,
Fiona