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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 56
    Questions
  • 19
    Replies
Dear gurus,

I need  To build LWC component Interactive calendar to display products from Salesforce

Below is base query :-
[SELECT Id,Name,Calendar_Start_Date_Time__c,Calendar_End_Date_Time__c,Description,Topics__c from Product2];
Now i want below things:-
  • Ability to search the Calendar when i type a text say "Mass Communication training" on text box then calendar date should get displayed
  • Ability to filter the calenda i.e. Filters shuld be defined by the values returned in query's Topics__c
  • Ability for on click function when user clicks on event. then Display a modal based on product id,below is the example of final results
User-added image

Appreciate the help,thanks in advance

Fiona

 
Hi,
i need to send current case to lightning component and wrote below apex but seems i am not able to send current case record  id to lightning component,any solution
 
public static Case getCaseFromId(Id caseID) { 


    if(caseID == null) {
            return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1];
        }
    
     List<Case> cases = [ SELECT Id, Subject, Description, Status from CASE where ID = :caseID ];
        
        if(cases.size() == 0) {
            return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1];
        } else {
            return cases[0];
        }        

}
cmp file
<aura:attribute name="record" type="case[]"/>

controller file
var action = component.get("c.getCaseFromId");
    action.setCallback(this, function(response){
        var state = response.getState();
        if (state === "SUCCESS") {
          
            var navEvent = $A.get("e.force:navigateToSObject");
             alert("hello there!"+ component.get("v.record",response.getReturnValue())); 
            navEvent.setParams({

               "recordId": component.get("v.record",response.getReturnValue())

            });
            navEvent.fire();

Problem is alert shows "undefined" in browser that means something is wrong,any suggestions

Fiona
Dear pals,

How do i Get Case Id in Lightning such that after save Case is shown and not related list,

currently after save Most recent cases are shown ,i need to show the associated Case after save and not List view,how to achieve this

current apex class for list view is
@AuraEnabled 

public static List<ListView> getListViews() { 

    List<ListView> listviews = [SELECT Id, Name FROM ListView WHERE SobjectType = 'Case' and Name = 'Recently Viewed Cases']; 
    
    return listviews;

Lightning component cmp file is
 
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);

any help to display the Case itself after save is highly appreciated

Regards,
Fiona

 
Dear Gurus,

I have a need where in i require to execute below code in Anonymous block,

what changes i need to make in below scheduled apex to make it execute in anonymous block,i just need to execute the code 
 
global class ERT_CaseCopyBatch implements Database.Batchable<sObject>, Database.Stateful {
    private List<ERT_Case_Type__c> processedRecords;
global Database.QueryLocator start(Database.BatchableContext BC) {
    processedRecords = new List<ERT_Case_Type__c>();
    // 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,UniqueGUID__c  FROM ERT_Case_Type__c WHERE createddate = today AND IsProcessed__c = false';
    return Database.getQueryLocator(query);
}
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>();
   
    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,ERTUniqueGUID__c=exe.UniqueGUID__c));
       exe.IsProcessed__c = true;    
    }
    try {
        
        insert listCTD;
        //only successful batches will be processed 
        processedRecords.addAll(exeList);
        update processedRecords;
    } catch(Exception e) {
        System.debug(e);
    }
}   
global void finish(Database.BatchableContext BC) {
   
  
}
}

Thanks in advance,
Fiona
Dear Gurus,

I am starting with a new project where basically need to do Migration of Organization's current database to Salesforce and for that i want to create a customized set of objects, single-record editing of data and field history tracking

What I have Now ?
Now I have spreadsheets and detailed information that needs tracking question is How To Do Data Setup & Customization for such scenario

Like what woud be the first milestone

Regards,
Fiona
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 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