• Dolgoldy
  • NEWBIE
  • 50 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 27
    Replies
Hi ,
I Written test class, pass all the data but not getting conerage plz help
below is the class, test classs.
public class RetailLicenseController {
    
    
    
    
    @AuraEnabled
    public static Response createRetailLiscense( String jsonData,String customerID ){
        
        
        // Create a savepoint
        Savepoint savePointRec = Database.setSavepoint();
        
        try{
            
           Map<String,String> mpStatus = new Map<String,String>();
            
            system.debug('<<<<<<<jsonData>>>>>>' + jsonData);
            
            RetailLiscenseDTO objRetailLiscenseDTO = (RetailLiscenseDTO)JSON.deserialize(jsonData, RetailLiscenseDTO.class); 
            
            system.debug('<<<<<<<objRetailLiscenseDTO>>>>>>' + objRetailLiscenseDTO);
            
            
            //DML for Explosive
            
                    
            if( objRetailLiscenseDTO.ExplosiveClass!=null ){
                                
                BPCL_ROIR_License__c explosiveObj = new BPCL_ROIR_License__c() ;
                
                explosiveObj.Customer_name__c = customerID;
                explosiveObj.Certificate_Name__c = 'Explosive';            
                explosiveObj.License_No__c = objRetailLiscenseDTO.ExplosiveClass.ExplosiveLisenceNo;
                explosiveObj.License_Valid_From__c = fromStringToDate ( objRetailLiscenseDTO.ExplosiveClass.ExplosiveFrmDate );
                explosiveObj.License_Valid_Till__c = fromStringToDate ( objRetailLiscenseDTO.ExplosiveClass.ExplosiveTillDate );
                explosiveObj.License_Remarks__c = objRetailLiscenseDTO.ExplosiveClass.ExplosiveRemarks;
                
                insert explosiveObj;
                
                mpStatus.put('Explosive','Success');
                
                
            }
            
            
            //DML for DPSL
            
            if( objRetailLiscenseDTO.DPSLClass != null ){
                
               
                
                BPCL_ROIR_License__c DPSLObj = new BPCL_ROIR_License__c() ;
                
                DPSLObj.Customer_name__c = customerID;
                
                
                DPSLObj.Certificate_Name__c = 'DPSL'; 
                
                DPSLObj.Partners_Proprietor_Name__c = objRetailLiscenseDTO.DPSLClass.DPSLPartnersProprietorNo;
                DPSLObj.License_Valid_From__c =  fromStringToDate ( objRetailLiscenseDTO.DPSLClass.DPSLPartnersProprietorFrmDate ) ;
                DPSLObj.License_Valid_Till__c = fromStringToDate ( objRetailLiscenseDTO.DPSLClass.DPSLPartnersProprietorTillDate );
                DPSLObj.License_Remarks__c = objRetailLiscenseDTO.DPSLClass.DPSLPartnersProprietorRemarks;
                
                insert DPSLObj;
                
                mpStatus.put('DPSL','Success');
            }
            
            
            
            
            //DML for WandMClass
            
            if( objRetailLiscenseDTO.WandMClass != null ){
                
                
                BPCL_ROIR_License__c wandMLObj = new BPCL_ROIR_License__c() ;
                
                wandMLObj.Customer_name__c = customerID;
                
                wandMLObj.Certificate_Name__c = 'W&M'; 
                
                wandMLObj.License_No__c = objRetailLiscenseDTO.WandMClass.WandMLicenseNumber;
                wandMLObj.License_Valid_From__c = fromStringToDate ( objRetailLiscenseDTO.WandMClass.WandMFrmDate );
                wandMLObj.License_Valid_Till__c = fromStringToDate ( objRetailLiscenseDTO.WandMClass.WandMTillDate );
                wandMLObj.License_Remarks__c = objRetailLiscenseDTO.WandMClass.WandMRemarks;
                                
                insert wandMLObj;
                
                mpStatus.put('W&M','Success');
                
            }
            
            
            //DML for Air Guauge Calibration
            
            if( objRetailLiscenseDTO.AirGuaugeCalibrationClass != null ){
                
                
                BPCL_ROIR_License__c airguageObj = new BPCL_ROIR_License__c() ;
                
                airguageObj.Customer_name__c = customerID;
                
                airguageObj.Certificate_Name__c = 'Air Gauge Calibration'; 
                
                airguageObj.License_No__c = objRetailLiscenseDTO.AirGuaugeCalibrationClass.AirGuaugeLicenseNumber;
                airguageObj.License_Valid_From__c = fromStringToDate ( objRetailLiscenseDTO.AirGuaugeCalibrationClass.AirGuaugeFrmDate );
                airguageObj.License_Valid_Till__c = fromStringToDate ( objRetailLiscenseDTO.AirGuaugeCalibrationClass.AirGuaugeTillDate );
                airguageObj.License_Remarks__c = objRetailLiscenseDTO.AirGuaugeCalibrationClass.AirGuaugeRemarks;               
                
                insert airguageObj;
                
                mpStatus.put('AirGaugeCalibration','Success');
                
            }
            
            
            //DML for Trade license            
            
            BPCL_ROIR_License__c  tradeLicenseObj = new BPCL_ROIR_License__c() ;
            
            tradeLicenseObj.Customer_name__c = customerID;
            
            tradeLicenseObj.Certificate_Name__c = 'Trade license'; 
            
            tradeLicenseObj.Name_of_the_License_holder__c = objRetailLiscenseDTO.TradeLicenseClass.TradeLicenseHolderName;
            tradeLicenseObj.License_Valid_From__c = fromStringToDate ( objRetailLiscenseDTO.TradeLicenseClass.TradeLicenseFrmDate );
            tradeLicenseObj.License_Valid_Till__c = fromStringToDate ( objRetailLiscenseDTO.TradeLicenseClass.TradeLicenseTillDate );
            tradeLicenseObj.License_Remarks__c = objRetailLiscenseDTO.TradeLicenseClass.TradeLicenseRemarks;
            
            if( String.isNotBlank( objRetailLiscenseDTO.TradeLicenseClass.TradeLicenseHolderName) ){
                
                insert tradeLicenseObj;
                
                mpStatus.put('Tradelicense','Success');
                
            }
            
            
            //DML for ALPLicenseClass
            
            
            BPCL_ROIR_License__c  ALPObj = new BPCL_ROIR_License__c() ;
            
            ALPObj.Customer_name__c = customerID;
            
            ALPObj.Certificate_Name__c = 'ALPG License'; 
            
            ALPObj.License_No__c = objRetailLiscenseDTO.ALPLicenseClass.ALPLicenseNumber;
            ALPObj.License_Valid_From__c = fromStringToDate ( objRetailLiscenseDTO.ALPLicenseClass.ALPValidFrmDate );
            ALPObj.License_Valid_Till__c = fromStringToDate ( objRetailLiscenseDTO.ALPLicenseClass.ALPValidToDate );
            ALPObj.License_Remarks__c = objRetailLiscenseDTO.ALPLicenseClass.ALPRemarks;
            
            if( String.isNotBlank( objRetailLiscenseDTO.ALPLicenseClass.ALPLicenseNumber) ){
                
                insert ALPObj;
                
                mpStatus.put('ALPGLicense','Success');
                
            }
            
            
            //DML for CNG License
                        
            BPCL_ROIR_License__c  CNGObj = new BPCL_ROIR_License__c() ;
            
            CNGObj.Customer_name__c = customerID;
            
            CNGObj.Certificate_Name__c = 'CNG License'; 
            
            CNGObj.License_No__c = objRetailLiscenseDTO.CNGLicenseClass.CNGLicenseNumber;
            CNGObj.License_Valid_From__c = fromStringToDate ( objRetailLiscenseDTO.CNGLicenseClass.CNGLicenseValidFrmDate );
            CNGObj.License_Valid_Till__c = fromStringToDate ( objRetailLiscenseDTO.CNGLicenseClass.CNGLicenseValidToDate );
            CNGObj.License_Remarks__c = objRetailLiscenseDTO.CNGLicenseClass.CNGRemarks;
            
            if( String.isNotBlank( objRetailLiscenseDTO.CNGLicenseClass.CNGLicenseNumber) ){
                
                insert CNGObj;
                
                mpStatus.put('CNG','Success');
                
            }
            
            
            //DML for PAN
            
            BPCL_ROIR_License__c  PANObj = new BPCL_ROIR_License__c() ;
            
            PANObj.Customer_name__c = customerID;
            
            PANObj.Certificate_Name__c = 'PAN'; 
            
            PANObj.PAN_Number__c = objRetailLiscenseDTO.PANClass.PANNo;
            PANObj.License_Valid_From__c = fromStringToDate ( objRetailLiscenseDTO.PANClass.PANValidFrmDate );
            PANObj.License_Valid_Till__c = fromStringToDate ( objRetailLiscenseDTO.PANClass.PANValidTillDate );
            PANObj.License_Remarks__c = objRetailLiscenseDTO.PANClass.PANRemarks;
            
            if( String.isNotBlank( objRetailLiscenseDTO.PANClass.PANNo) ){
                
                insert PANObj;
                
                mpStatus.put('PAN','Success');
                
            }
            
            
            //DML for GST
            
            
            
            BPCL_ROIR_License__c  GSTObj = new BPCL_ROIR_License__c() ;
            
            GSTObj.Customer_name__c = customerID;
            
            GSTObj.Certificate_Name__c = 'GST'; 
            
            GSTObj.GST_Number__c = objRetailLiscenseDTO.GSTClass.GSTNumber;
            GSTObj.License_Valid_From__c = fromStringToDate ( objRetailLiscenseDTO.GSTClass.GSTValidFrmDate );
            GSTObj.License_Valid_Till__c = fromStringToDate ( objRetailLiscenseDTO.GSTClass.GSTValidTillDate );
            GSTObj.License_Remarks__c = objRetailLiscenseDTO.GSTClass.GSTRemarks;
            
            if( String.isNotBlank( objRetailLiscenseDTO.GSTClass.GSTNumber) ){
                
                insert GSTObj;
                
                mpStatus.put('GST','Success');
            }
                        
            if(mpStatus.size()==0){
                
                return new Response(false, null, 'Exception occured while submitting form, Please Try again.');
                
            }else{
                
                return new Response(true, objRetailLiscenseDTO, 'Retail Licenses has been Saved Successfully!');
            }
            
            
            
            
        }Catch(Exception ex){
            System.debug('<<<<<<<Exception occured in createRIOR, Exception>>>>>>>>>' + ex.getMessage() + ', on line ' + ex.getLineNumber()); 
            // Rollback operation
            Database.rollback(savePointRec);            
            return new Response(false, null, 'Exception occured while submitting form, Please Try again.');
            //return new Response(false, null, 'Exception occured while submitting form, Exception: ' + ex.getMessage() + ', on line ' + ex.getLineNumber() );
        }
        
    }
    
    // Convert String to Date //16/11/2022
    public static Date fromStringToDate(String DateStr){
        
        Date convertedDate;
        
        system.debug('>>>>DateStr>>>'+DateStr); //2022-11-23
        
        if( String.isNotBlank(DateStr) ){
            List<String> intLst=DateStr.split('-');
            String yearStr = intLst[0];
            string monthStr = intLst[1];
            string dayStr = intLst[2];
            
            string strDate = yearStr + '-' + monthStr + '-' + dayStr ;
            convertedDate = Date.valueOf(strDate );
        }
        return convertedDate ;
    }
    
    
    
    
}
 
@isTest
public class RetailLicenseControllerTest {
    
     @isTest
    static void test(){
       Account accParent = new Account(Name ='test Account11',
                                  RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Retail').getRecordTypeId(),
                                  BillingStreet = 'test', 
                                  BillingCity='Chicago', 
                                  BillingState = 'Illinois', 
                                  BillingCountry='United States',
                                  BillingPostalCode = '60657',
                                  Busniess_Unit__c ='Retail',
                                  Customer_Type__c	='RO Dealers(Channel Partner)',
                                  Email_Id__c ='test@gmail.com',
                                  BL_Number__c = '123',     
                                  Sales_Area_Code_Text__c = '3102',
                                  Active__c = true
                                       
                                 );
        insert accParent;
       
        //Create Distributer
        Account acc = new Account(Name ='test Account112',
                                  ParentId = accParent.Id,
                                  RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Retail').getRecordTypeId(),
                                  BillingStreet = 'test', 
                                  BillingCity='Chicago', 
                                  BillingState = 'Illinois', 
                                  BillingCountry='United States',
                                  BillingPostalCode = '60657',
                                  Busniess_Unit__c ='Retail',
                                  Customer_Type__c	='RO Dealers(Channel Partner)',
                                  Email_Id__c ='test@gmail.com',
                                    BL_Number__c = '123',     
                                  Sales_Area_Code_Text__c = '512',
                                  Active__c = true
                                 );
        insert acc;     
       
        
     // Explosive
       
       BPCL_ROIR_License__c ObjLicense_1 = new BPCL_ROIR_License__c();
        
		ObjLicense_1 .Certificate_Name__c ='Explosive'; 
 		ObjLicense_1.Certificate_Number__c = 'Test123';
        ObjLicense_1.Customer_name__c = acc.ID ;
        ObjLicense_1.License_No__c = 'LC-0056' ;
        ObjLicense_1.License_Valid_From__c =  Date.today().addDays(30);
       ObjLicense_1.License_Valid_Till__c = Date.today();
         ObjLicense_1.License_Remarks__c = 'Test';
         
       Insert ObjLicense_1;
        
        //  DPSL
        
           BPCL_ROIR_License__c ObjLicense_2 = new BPCL_ROIR_License__c();
        
		ObjLicense_2 .Certificate_Name__c ='DPSL'; 
 		ObjLicense_2.Certificate_Number__c = 'Test123';
        ObjLicense_2.Customer_name__c = acc.ID ;
        ObjLicense_2.License_No__c = 'LC-0056' ;
        ObjLicense_2.License_Valid_From__c =  Date.today().addDays(30);
       ObjLicense_2.License_Valid_Till__c = Date.today();
         ObjLicense_2.License_Remarks__c = 'Test';
         
       Insert ObjLicense_2;
        
        //W&M
        
        BPCL_ROIR_License__c ObjLicense_3 = new BPCL_ROIR_License__c();
        
		ObjLicense_3 .Certificate_Name__c ='W&M'; 
 		ObjLicense_3.Certificate_Number__c = 'Test123';
        ObjLicense_3.Customer_name__c = acc.ID ;
        ObjLicense_3.License_No__c = 'LC-0056' ;
        ObjLicense_3.License_Valid_From__c =  Date.today().addDays(30);
       ObjLicense_3.License_Valid_Till__c = Date.today();
         ObjLicense_3.License_Remarks__c = 'Test';
         
       Insert ObjLicense_3;
        
        //Air Gauge Calibration
        
        BPCL_ROIR_License__c ObjLicense_4 = new BPCL_ROIR_License__c();
        
		ObjLicense_4 .Certificate_Name__c ='Air Gauge Calibration'; 
 		ObjLicense_4.Certificate_Number__c = 'Test123';
        ObjLicense_4.Customer_name__c = acc.ID ;
        ObjLicense_4.License_No__c = 'LC-0056' ;
        ObjLicense_4.License_Valid_From__c =  Date.today().addDays(30);
       ObjLicense_4.License_Valid_Till__c = Date.today();
         ObjLicense_4.License_Remarks__c = 'Test';
         
       Insert ObjLicense_4;
        
        //Trade license
        
        
           BPCL_ROIR_License__c ObjLicense_5 = new BPCL_ROIR_License__c();
        
		ObjLicense_5.Certificate_Name__c ='Air Gauge Calibration'; 
 		ObjLicense_5.Certificate_Number__c = 'Test123';
        ObjLicense_5.Customer_name__c = acc.ID ;
        ObjLicense_5.License_No__c = 'LC-0056' ;
        ObjLicense_5.License_Valid_From__c =  Date.today().addDays(30);
       ObjLicense_5.License_Valid_Till__c = Date.today();
         ObjLicense_5.License_Remarks__c = 'Test';
         
       Insert ObjLicense_5;
        
        //ALPG License
      
         BPCL_ROIR_License__c ObjLicense_6 = new BPCL_ROIR_License__c();
        
		ObjLicense_6.Certificate_Name__c ='ALPG License'; 
 		ObjLicense_6.Certificate_Number__c = 'Test123';
        ObjLicense_6.Customer_name__c = acc.ID ;
        ObjLicense_6.License_No__c = 'LC-0056' ;
        ObjLicense_6.License_Valid_From__c =  Date.today().addDays(30);
       ObjLicense_6.License_Valid_Till__c = Date.today();
         ObjLicense_6.License_Remarks__c = 'Test';
         
       Insert ObjLicense_6;
        
        //CNG License
        
          BPCL_ROIR_License__c ObjLicense_7 = new BPCL_ROIR_License__c();
        
		ObjLicense_7.Certificate_Name__c ='CNG License'; 
 		ObjLicense_7.Certificate_Number__c = 'Test123';
        ObjLicense_7.Customer_name__c = acc.ID ;
        ObjLicense_7.License_No__c = 'LC-0056' ;
        ObjLicense_7.License_Valid_From__c =  Date.today().addDays(30);
       ObjLicense_7.License_Valid_Till__c = Date.today();
         ObjLicense_7.License_Remarks__c = 'Test';
         
       Insert ObjLicense_7;
        
        //PAN
       
         BPCL_ROIR_License__c ObjLicense_8 = new BPCL_ROIR_License__c();
        
		 ObjLicense_8.Certificate_Name__c ='PAN'; 
 		 ObjLicense_8.Certificate_Number__c = 'Test123';
         ObjLicense_8.Customer_name__c = acc.ID ;
         ObjLicense_8.License_No__c = 'LC-0056' ;
         ObjLicense_8.License_Valid_From__c =  Date.today().addDays(30);
       ObjLicense_8.License_Valid_Till__c = Date.today();
          ObjLicense_8.License_Remarks__c = 'Test';
         
       Insert  ObjLicense_8;
        
       Test.startTest();
        
        RetailLicenseController.createRetailLiscense('jsonData',acc.Id);
        RetailLiscenseDTO objDto = new RetailLiscenseDTO();
         objDto.ExplosiveClass.ExplosiveLisenceNo = 'Test 123';
		objDto.ExplosiveClass.ExplosiveRemarks = 'Test'; 
        objDto.ExplosiveClass.ExplosiveFrmDate = 'Date.today().addDays(30)';
        objDto.ExplosiveClass.ExplosiveTillDate = 'Date.today()';
     
        Test.stopTest();
     
       
   }


}
 
public class RetailLiscenseDTO {
    
    
    @AuraEnabled public ExplosiveClass ExplosiveClass{get;set;}   
    
    @AuraEnabled public DPSLClass DPSLClass{get;set;}
    
    @AuraEnabled public WandMClass WandMClass{get;set;}
    
    @AuraEnabled public AirGuaugeCalibrationClass AirGuaugeCalibrationClass{get;set;}
    
    @AuraEnabled public TradeLicenseClass TradeLicenseClass{get;set;}
    
    @AuraEnabled public ALPLicenseClass ALPLicenseClass{get;set;}
    
    @AuraEnabled public CNGLicenseClass CNGLicenseClass{get;set;}
    
    @AuraEnabled public PANClass PANClass{get;set;}
    
    @AuraEnabled public GSTClass GSTClass{get;set;}  
    
    
    public RetailLiscenseDTO(){
        
        this.ExplosiveClass = new ExplosiveClass();
        
        this.DPSLClass = new DPSLClass(); 
        
        this.WandMClass = new WandMClass(); 
        
        this.AirGuaugeCalibrationClass = new AirGuaugeCalibrationClass(); 
        
        this.TradeLicenseClass = new TradeLicenseClass();
        
        this.ALPLicenseClass = new ALPLicenseClass();
        
        this.CNGLicenseClass = new CNGLicenseClass(); 
        
        this.PANClass = new PANClass();
        
        this.GSTClass = new GSTClass();
        
    }
    
    
    //ExplosiveClass
    Public class ExplosiveClass{
        
        @AuraEnabled public String ExplosiveLisenceNo{get;set;} 
        @AuraEnabled public String ExplosiveFrmDate{get;set;} 
        @AuraEnabled public String ExplosiveTillDate{get;set;} 
        @AuraEnabled public String ExplosiveRemarks{get;set;} 
        
    }
    
    //DPSLClass
    Public class DPSLClass{
        
        @AuraEnabled public String DPSLPartnersProprietorNo{get;set;} 
        @AuraEnabled public String DPSLPartnersProprietorFrmDate{get;set;} 
        @AuraEnabled public String DPSLPartnersProprietorTillDate{get;set;} 
        @AuraEnabled public String DPSLPartnersProprietorRemarks{get;set;} 
        
    }
    
    //WandMClass
    Public class WandMClass{
        
        @AuraEnabled public String WandMLicenseNumber{get;set;} 
        @AuraEnabled public String WandMFrmDate{get;set;} 
        @AuraEnabled public String WandMTillDate{get;set;} 
        @AuraEnabled public String WandMRemarks{get;set;} 
        
        
    }
    
    //AirGuaugeCalibrationClass
    Public class AirGuaugeCalibrationClass{
        
        @AuraEnabled public String AirGuaugeLicenseNumber{get;set;} 
        @AuraEnabled public String AirGuaugeFrmDate{get;set;} 
        @AuraEnabled public String AirGuaugeTillDate{get;set;} 
        @AuraEnabled public String AirGuaugeRemarks{get;set;} 
        
    }
    
    //TradeLicenseClass
    Public class TradeLicenseClass{
        
        @AuraEnabled public String TradeLicenseHolderName{get;set;} 
        @AuraEnabled public String TradeLicenseFrmDate{get;set;} 
        @AuraEnabled public String TradeLicenseTillDate{get;set;} 
        @AuraEnabled public String TradeLicenseRemarks{get;set;} 
        
    }
    
    //ALPLicenseClass
    Public class ALPLicenseClass{
        
        @AuraEnabled public String ALPLicenseNumber{get;set;} 
        @AuraEnabled public String ALPValidFrmDate{get;set;} 
        @AuraEnabled public String ALPValidToDate{get;set;} 
        @AuraEnabled public String ALPRemarks{get;set;} 
        
    }
    
    
    //CNGLicenseClass
    Public class CNGLicenseClass{
        
        @AuraEnabled public String CNGLicenseNumber{get;set;} 
        @AuraEnabled public String CNGLicenseValidFrmDate{get;set;} 
        @AuraEnabled public String CNGLicenseValidToDate{get;set;} 
        @AuraEnabled public String CNGRemarks{get;set;} 
        
    }
    
    //PANClass
    Public class PANClass{
        
        @AuraEnabled public String PANNo{get;set;} 
        @AuraEnabled public String PANValidFrmDate{get;set;} 
        @AuraEnabled public String PANValidTillDate{get;set;} 
        @AuraEnabled public String PANRemarks{get;set;} 
        
    }
    
    //GSTClass
    Public class GSTClass{
        
        @AuraEnabled public String GSTNumber{get;set;} 
        @AuraEnabled public String GSTValidFrmDate{get;set;} 
        @AuraEnabled public String GSTValidTillDate{get;set;} 
        @AuraEnabled public String GSTRemarks{get;set;} 
    }
    
    
    
}

 
Hi all,
Here Added all the fields in Field dependecies and record type but in ui in aura componet shown only one value not getting why???
Plz help
User-added imageHere add all fields in record typeBut in Ui After selecting Digital Buisness only value are displaying
Hi all, there is program and sbu field which is dependent but newly added value in program not showing on ui. I adde in field dependency and record type
// apex class

 public static List<String> DigitalProgramPicklistValues(String sbu, String interactionType, String program){
        Set<String> pickListSet = new Set<String>(); 
        List<String> pickListList = new List<String>(); 
        String cmQuery;
        try {
            System.debug('sbu :: ' + sbu);
            System.debug('program :: ' + program);
            cmQuery = 'Select Id, Interaction_Type__c, Program__c, SBU__c,  FROM case where SBU__c =: sbu AND Program__c =: program';
            if(sbu == 'Digital Buisness'){
                for(Case ca : Database.query(cmQuery)){
                    pickListSet.add(ca.Program__c);
                }
                System.debug('Programs :: ' + pickListSet);
            }
            else if(program == ''){
                cmQuery += ' AND sbu__c =: sbu';
                System.debug('program QUERY :: ' + cmQuery);
                for(Case ca : Database.query(cmQuery)){
                    System.debug('program :: ' + pickListSet);
                    pickListSet.add(ca.program__c);
                }
                System.debug('program :: ' + pickListSet);
            }
           /* else if(subCategory == ''){
                cmQuery += ' AND __c =: program AND Category__c =: category';
                System.debug('Query :: ' + cmQuery);
                for(Category_Master__c cm : Database.query(cmQuery)){
                    pickListSet.add(cm.Sub_Category__c);
                }
                System.debug('subCategory :: ' + pickListSet);
            }

            for(String str: pickListSet){
                pickListList.add(str);
            }*/
            // return programSet;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
        return pickListList;
    }
 
// helper class

 // digital Buisness changes
     programPicklistValues1: function (cmp, event) {
        var action = cmp.get("c.DigitalProgramPicklistValues");
        var selectProgramValue = cmp.find('ProgramField').get('v.value');
        var selectInteractionValue = cmp.find('Interactiontypefield').get('v.value');
        console.log('Program :: ' + selectProgramValue);
        console.log('Interaction Type :: ' + selectInteractionValue);
        action.setParams({
            sbu: cmp.find('ProgramField').get('v.value'),
            interactionType: cmp.find('Interactiontypefield').get('v.value'),
            sbu: '',
            program: '',
            //subCategory: ''
        });
        // cmp.get("!v.Case_Record.SBU__c")
        // cmp.get("!v.Case_Record.Interaction_Type__c" )
        // var selectValue = cmp.find('SBUField').get('v.value');
        // console.log('type ' + cmp.find('Interactiontypefield').get('v.value'));

        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                // Alert the user with the value returned 
                // from the server
                // alert("From server: " + response.getReturnValue());

                var programValues = [];
                sbuValues = response.getReturnValue();
                console.log('sbu Values:: '+  response.getReturnValue());
                var buList = [];
                buList.push({class: "optionClass",label: "--- Select one ---",value: ""});
                for(var i=0; i<sbuValues.length; i++){
                    console.log('Key::'+ sbuValues[i]);
                    buList.push({class: "optionClass",label:sbuValues[i],value:sbuValues[i]})
                }
                console.log(buList);
                cmp.set("v.sbuList", buList);

                // cmp.set("v.programList", response.getReturnValue());
                // You would typically fire a event here to trigger 
                // client-side notification that the server-side 
                // action is complete
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    sbuChange: function(cmp, event){
        console.log('event::'+event)
        console.log('fg '+ event.getSource());
        var Sbu = event.getSource().get("v.value");
        cmp.set("v.Case_Record.sbu__c", sbu);
        console.log("sbu :: " + sbu);

        var action = cmp.get("c.DigitalProgramPicklistValues");
        action.setParams({
            sbu: cmp.find('ProgramField').get('v.value'),
            interactionType: cmp.find('Interactiontypefield').get('v.value'),
            sbu: cmp.get("v.Case_Record.sbu__c"),
            program: '',
            //subCategory: ''
        });

        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {

                var ProgramValues = [];
                ProgramValues = response.getReturnValue();
                var buList2 = [];
                buList2.push({label: "--- Select one ---",value: ""});
                for(var i=0; i<programValues.length; i++){
                    console.log('Key::'+ programValues[i]);
                    buList2.push({label:programValues[i],value:programValues[i]});
                }
                console.log(buList2);
                cmp.set("v.programList", buList2);
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);

    },
    programChange: function(cmp, event){
        console.log('fg '+ event.getSource());
        var category = event.getSource().get("v.value");
        //cmp.set("v.categorySelected", category);
        console.log("program :: " + event.getSource().get("v.value"));
        cmp.set("v.Case_Record.program__c", event.getSource().get("v.value"));
        var program = cmp.get('v.Case_Record.sbu__c');
        var action = cmp.get("c.DigitalProgramPicklistValues");
        action.setParams({
            sbu: cmp.find('ProgramField').get('v.value'),
            interactionType: cmp.find('Interactiontypefield').get('v.value'),
            program: cmp.get("v.Case_Record.SBU__c"),
            category: cmp.get("v.Case_Record.Program__c"),
          //  subCategory: ''
        });
    },
 
js controller

   // to display program picklist for digital buisness
          var selectValue = cmp.find('ProgramField').get('v.value');
         console.log('type ' + cmp.find('ProgramField').get('v.value'));
        
  digitalProgram: function (cmp, event, helper) {
        // cmp.set("v.isNextBtnDisabled", true);
        helper.programPicklistValues1(cmp, event);
        helper.showSpinners(cmp);
        },

 
Hi all,
New to aura component. want to add "Digital " value in Sbu picklist field using aura plz help in below code
<!-- attribute to hold the SBU-Interaction Type value-->
    <aura:attribute name="headerValue" type="string" default="" /> 
    
    <!-- attribute to hold the SBU Boolean value-->
    <aura:attribute name="isAviation" type="Boolean" default="false" />
    <aura:attribute name="isLPG" type="Boolean" default="false" />
    <aura:attribute name="isGas" type="Boolean" default="false" />
    <aura:attribute name="isLubes" type="Boolean" default="false" />
    <aura:attribute name="isRetail" type="Boolean" default="false" />
    <aura:attribute name="isI_C" type="Boolean" default="false" />
		
    
    <!--Aura Init function-->    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <lightning:workspaceAPI aura:id="workspace" />
    <lightning:navigation aura:id="navService" />
    <ltng:require styles="{!$Resource.largeModal}" />
    <ltng:require scripts="/support/console/34.0/integration.js" />


    <!--case Creation Popup Window-->
    <div class="slds-modal__container">
        <header class="slds-modal__header HeaderCss">
            <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate" >Interaction</h2>
        </header>
        <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
            <lightning:spinner aura:id="mySpinner" alternativeText="Processing.." title="Processing.." variant="brand"
                               size="large" class="slds-hide" />
            <lightning:recordEditForm aura:id="myform" onerror="{!c.onError}" onload="" onsubmit="{!c.handlesubmit}" onsuccess="{!c.handleSuccess}" objectApiName="Case">
                <aura:if isTrue="{!v.showError}"> 
                    <c:ToastError visible="{!v.showError}" contents="{!v.errorMessage}" />
                </aura:if>
                <!--Screen 1 Details-->
                <div aura:id="firstsection" class="{!if(v.displayedSection == 'section1','slds-show','slds-hide')}">                 
                    <!--<c:ToastError visible="{!v.showError}" contents="{!v.errorMessage}" />-->
                    <!--SBU-InteractionType-->
                    <div class="slds-grid slds-gutters">
                        <div class="slds-col slds-size_6-of-12">
                            <lightning:inputField fieldName="SBU__c" value="{!v.Case_Record.SBU__c}"
                                                  aura:id="SBUField" required="true" onchange="{!c.getHeaderValue}" />
                        </div>
                        <div class="slds-col slds-size_6-of-12">
                            <lightning:inputField fieldName="Interaction_Type__c" value="{!v.Case_Record.Interaction_Type__c}" 
                                                  aura:id="Interactiontypefield" required="true" onchange="{!c.getHeaderValue}"/>
                        </div>
                    </div>
 
Hi all, help me to write test class
public class myjob 
{
@AuraEnabled(cacheable=true)
    Public static List<Job_Requirement__c> myservice()
    {
        list<Job_Requirement__c> lstjob = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Standard'];
        return lstjob;
    }

@AuraEnabled(cacheable=true)
    Public static List<Job_Requirement__c> myservicegeneral()
    {
        list<Job_Requirement__c> lstjobgeneral = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Specialty'];
        return lstjobgeneral;
    }
    @AuraEnabled(cacheable=true)
    Public static List<Job_Requirement__c> myservicinteriror()
    {
        list<Job_Requirement__c> lstjobinteriror = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Custom Named'];
        return lstjobinteriror;
    }

    @AuraEnabled(cacheable=false)
    Public static List<Job_Requirement__c> getStandardWorkOrders()
    {
        list<Job_Requirement__c> lstjob = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c ];
                                          //Type__c='Standard'];
        return lstjob;
    }

    Public static List<Job_Requirement__c> getSpecialityWokOrders()
    {
        list<Job_Requirement__c> lstjobgeneral = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Specialty'];
        return lstjobgeneral;
    }
}
HI all 
please help me to write test class
public class myjob 
{
@AuraEnabled(cacheable=true)
    Public static List<Job_Requirement__c> myservice()
    {
        list<Job_Requirement__c> lstjob = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Standard'];
        return lstjob;
    }

@AuraEnabled(cacheable=true)
    Public static List<Job_Requirement__c> myservicegeneral()
    {
        list<Job_Requirement__c> lstjobgeneral = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Specialty'];
        return lstjobgeneral;
    }
    @AuraEnabled(cacheable=true)
    Public static List<Job_Requirement__c> myservicinteriror()
    {
        list<Job_Requirement__c> lstjobinteriror = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Custom Named'];
        return lstjobinteriror;
    }

    @AuraEnabled(cacheable=false)
    Public static List<Job_Requirement__c> getStandardWorkOrders()
    {
        list<Job_Requirement__c> lstjob = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c ];
                                          //Type__c='Standard'];
        return lstjob;
    }

    Public static List<Job_Requirement__c> getSpecialityWokOrders()
    {
        list<Job_Requirement__c> lstjobgeneral = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Specialty'];
        return lstjobgeneral;
    }
}

 
want to check records which is already  inserted in lwc.datatable.this the code below
// Html file

<template>
    <!-- lightning button for open modal window -->
    <lightning-button variant="brand" label="Add New Work Order" title="What is Modal/PopUp in LWC?" onclick={openModal}
    class="slds-float_right">
    </lightning-button>

// JS code

   openModal() {
        // to open modal set isModalOpen tarck value as true             
        this.fetchStandardWorkOrders();
    }

fetchStandardWorkOrders(){
        getStandardWorkOrders({})
        .then(res=> {
            let generalarray = [];
            let specailtyWO = [];
            let customNamedWO = [];
            res.forEach(element => {
                    if(element.Type__c == 'Standard'){
                        generalarray.push(element);
                    }
                    else if(element.Type__c == 'Specialty'){
                        specailtyWO.push(element);
                    }
                    else if(element.Type__c == 'Custom Named'){
                        customNamedWO.push(element);
                    }
                });           
            this.generalarray = generalarray;
            this.customNamedWO = customNamedWO;
            this.specailtyWO = specailtyWO;
            this.isModalOpen = true;   
        })
        .catch(err=> {
            console.log(err);
        })
    }


 
HI all,
There is one field i.e. work order which is not feching data from ui please tell me resson below is my code
// apex class

public with sharing class ProjectLineItemHelper

  {
    @AuraEnabled(cacheable=true)
      public static List<Project_Line_Items__c> getprojectlineItemList(id projectId) {
       system.debug('prjId >> ' + projectId);
        return[SELECT Id, Name, Area_Of_House__c, QTY_Type__c, qty__c, Rate__c, total__c,Line_Item_Status__c,Projects__c,Master_Line_Items_List__r.name,
        Project_Work_Order__r.name,Decription__c FROM Project_Line_Items__c where Projects__c=:projectId];
            
             }
          /*   @AuraEnabled(cacheable=true)
      public static List<Project_Line_Items__c> getprojectlineItemWorkOrderList(id projectId) {
       system.debug('prjId >> ' + projectId);
        return[SELECT Id, Name, Area_Of_House__c, QTY_Type__c, qty__c, Rate__c, total__c,Line_Item_Status__c,Projects__c,Master_Line_Items_List__r.name,
        Project_Work_Order__r.name,Decription__c FROM Project_Line_Items__c where Projects__c=:projectId];
            
             }*/
      
      
}
 
// .js file

import { LightningElement ,api, wire, track} from 'lwc';
import getprojectlineItemList from '@salesforce/apex/ProjectLineItemHelper.getprojectlineItemList';
//import getprojectlineItemWorkOrderList from '@salesforce/apex/ProjectLineItemHelper.getprojectlineItemWorkOrderList';
export default class projectLineItemAddTable extends LightningElement {
     @api recordId;
    // @api recordid;

    @track columns = [{label: 'Work Order name',
            fieldName: ' Project_Work_Order__c',
            type: 'text',
            sortable: true

    },
        {
            label: 'Line Item name',
            fieldName: 'Name',
            type: 'text',
            sortable: true
        },
        {
            label: 'Description',
            fieldName: 'Decription__c',
           type : 'Text',
            sortable: true
        },
        {
            label: 'Area of House',
            fieldName: 'Area_Of_House__c',
          type: 'picklist',
            sortable: true
        },
       {
            label: 'Status',
            fieldName: 'Line_Item_Status__c',
           type: 'picklist',
            sortable: true
        },
        {
            label: 'Qty Type',
            fieldName: 'QTY_Type__c',
          type : 'picklist',
            sortable: true
        },
        {
            label: 'Qty',
            fieldName: 'QTY__c',
            type: 'text',
 	        sortable: true
        },
        {
            label: 'Rate',
            fieldName: 'Rate__c',
            type: 'currency',
            sortable: true
        },
	{
            label: 'Total',
            fieldName: 'Total__c',
           type : 'text',
            sortable: true
        },
        
    ];
 
    @track error;

    @track lineItemList ;
    //selectedWOName = '';



    //to filterline item  record using project id
    @wire(getprojectlineItemList, {projectId : '$recordId'})
    wiredProjectlineItems({
        error,
        data
    }) {
       
        if (data) {
            this.lineItemList = data;
        } else if (error) {
            this.error = error;
        }
    }

    connectedCallback(){
        console.log('project ID' + this.recordId);
    }
    // to filter work order
    /* @wire( getprojectlineItemWorkOrderList, {projectId : '$recordId'})
    wiredProjectlineItems({
        error,
        data
    }) {
       
        if (data) {
            this.lineItemList = data;
        } else if (error) {
            this.error = error;
        }
    }

    connectedCallback(){
        console.log('project ID' + this.recordId);
    }*/


}
 
//, Html
<template>
    <!--h1 font-size:60px> Project Line Items</h1-->
     <div class="slds-box slds-theme_default">
    <lightning-card>
      <h3 slot="title" class="slds-text-title_bold">
        <lightning-icon
          icon-name="standard:client"
          size="medium">
        </lightning-icon>
        <span class="slds-m-left_small">
          Project Line Items</span>
        
      </h3>
    <!-- <template if:true={lineItemList}> -->
        <lightning-datatable data={lineItemList} columns={columns} key-field="Id"  hide-checkbox-column="true" >
            
 
        </lightning-datatable>
    <!-- </template> -->
    
    <template if:true={error}>
        {error}
    </template>
    </lightning-card>
    </div>
</template>


 
Hi all,
I am new to integration & I want to perform integration using swagger ui,
I want to transper swagger ui id to affiliateId. can anyone help me to solve that one its urgent.
The manditory fields using swagger for integration are
affiliateIntegrationId integer($int32)
affiliateId* integer($int32)
affiliateIntegrationCode* string
affiliateStatus* string
affiliateIntegrationType* string 
@istest
Public class DateMathHelperTest {
    @isTest 
     static void DateMathHelpermethod1(){
	
	  
	     Epix_Date_Math_Logic__c edml  = new Epix_Date_Math_Logic__c();
		 //edml.name = 'test';
		edml.Logic__c = 'latest of';
		 edml.Calculated_Date__c = system.today();
		 insert edml;
		 
		 List<Epix_Date_Math__c> listedm = new List<Epix_Date_Math__c>();
        
         Epix_Date_Math__c edm = new Epix_Date_Math__c( Epix_Date_Math_Logic__c=edml.id);
													
        listedm.add(edm);
		insert listedm; 						
        
        Test.startTest();
         DateMathHelper objDt =new DateMathHelper();
         objDt.calculateDateMath(listedm);
        	//DateMathHelper.calculateDateMath(listedm);
        Test.stopTest();
    } 
	
	@isTest 
    Public static void DateMathHelpermethod2(){
	
	  
	     Epix_Date_Math_Logic__c edml  = new Epix_Date_Math_Logic__c();
		// edml.name = 'test';
		 edml.Calculated_Date__c = system.today();
		 insert edml;
		 
		 List<Epix_Date_Math__c> listedm = new List<Epix_Date_Math__c>();
        
        
         Epix_Date_Math__c edm = new Epix_Date_Math__c(  Epix_Date_Math_Logic__c=edml.id);
        listedm.add(edm);
		insert listedm; 						
        
        Test.startTest();
         DateMathHelper objDt2 =new DateMathHelper();
         objDt2.calculateDateMath(listedm);
        	//DateMathHelper.calculateDateMath(listedm);
        Test.stopTest();
    }
	
	@isTest 
    Public static void DateMathHelpermethod3(){
	
	  
	     Epix_Date_Math_Logic__c edml  = new Epix_Date_Math_Logic__c();
		 //edml.name = 'test';
		 edml.Logic__c ='Latest Of';
		 edml.Calculated_Date__c = system.today();
		 insert edml;
		 
		 List<Epix_Date_Math__c> listedm = new List<Epix_Date_Math__c>();
        
       Epix_Date_Math__c edm = new Epix_Date_Math__c(Epix_Date_Math_Logic__c=edml.id); 
													
        listedm.add(edm);
		insert listedm; 						
        
        Test.startTest();
         DateMathHelper objDt3 =new DateMathHelper();
         objDt3.calculateDateMath(listedm);
        	//DateMathHelper.calculateDateMath(listedm);
        Test.stopTest();
    }
	
	
   @Istest
Public static void DateMathHelpermethod4(){
	
	 List<Epix_Date_Math_Logic__c> listedml = new List<Epix_Date_Math_Logic__c>();
	   
	   
	   Milestone__c m = new Milestone__c();
	  // m.Name = 'test';
        m.XB_EPX_Notes__c='test notes';
	   insert m;
	   
	
	   Pickup_Options__c po = new Pickup_Options__c();
	  // po.name = 'test';
	  po.XB_EPX_Season_Finale_Delivery__c=system.today();
        po.XB_EPX_Term_Length__c='test1';
	   insert po;
	   
	   
	   Opportunity opp = new Opportunity();
	   opp.Name = 'test opp';
	   opp.stageName = 'Prospect';
	   opp.closedate = system.today()+4;
	   insert opp;
	
	  
	     Epix_Date_Math_Logic__c edml  = new Epix_Date_Math_Logic__c();
		 //edml.name = 'test';
		 //edml.Logic__c ='Latest Of';
		 edml.Calculated_Date__c = system.today();
		// edml.Destination_Milestone__c = m.id;
		// edml.Column_Api__c = 'test';
		 edml.Destination_Pickup_Option__c = po.id;
		 edml.Destination_Opportunity__c = opp.id;
		 listedml.add(edml);
		 
		Insert listedml;
		 
		 List<Epix_Date_Math__c> listedm = new List<Epix_Date_Math__c>();
        
        
        Epix_Date_Math__c edm = new Epix_Date_Math__c(Epix_Date_Math_Logic__c=listedml[0].id);
        listedm.add(edm);
		insert listedm; 						
        
       Test.startTest();
         DateMathHelper objDt4 =new DateMathHelper();
       objDt4.updateDateMathLogic(listedml);
        
        Test.stopTest();
    }
	
}

Here getting error as 'unexpectd token from'
plz help me out to solve this issue
HI all, 
I amm beginner in apex so please help me to write test class for below handler class
*********Write test class for below class***********


public class TestHelper {
    public static Integer TestCounter1 = 0;
    public static Integer TestCounter2 = 0;
    
    public void DataTEst(List<TEst__c> objtest) {
        Set<Id> logicIds = new Set<Id>();
        
        for(TEst__c te : objtes) {		
            logicIds.add(te.TEstLogic__c);
        }
        
      
        
        AggregateResult [] TestAgg = [Select TEstLogic__c, MIN(Date__c) Earliest, MAX(Date__c) Latest
                                            from TEst__c Where TEstLogic__c IN :logicIds Group BY TEstLogic__c];
        
      
        
        Map<Id, TEstLogic__c> logicMap = new Map<Id, TEstLogic__c>([Select Id, Logic__c, Date__c from TEstLogic__c Where ID IN :logicIds]);
        
        List<TEstLogic__c> logicToUpdate = new List<TEstLogic__c>();
        
        
        Set<Id> tdblogicIDs = new Set<Id>();
       
        for(Test__c M : [Select TEstLogic__c from test__c Where TEstLogic__c__c IN :logicIds and Date__c = null])
        {
            tdblogicIDs.add(M.Epix_Date_Math_Logic__c);
        }
        
        for (AggregateResult ar : mathAggregate) {
            String logicId = (String)ar.get('TEstLogic__c');
            if(logicMap.containsKey(logicId)){
                TEstLogic__c logic = logicMap.get(logicId);   
                
                if(logic.Logic__c == 'Earliest Of' || logic.Logic__c == 'Equals')
                {
                    if(tdblogicIDs.contains(logicId)){
                        logic.Date__c = null;
                    }else {
                    	logic.Date__c = (Date)ar.get('Earliest');
                    }
                }else if(logic.Logic__c == 'Latest Of')
                    logic.Date__c = (Date)ar.get('Latest');
                
                logicToUpdate.add(logic);
            }        
        }
        
       
        update logicToUpdate; 
    }
    
    public void updateDateMathLogic(List<TEstLogic__c> dateLogicList) {
        
        Map<Id, String> testField1  = new Map<Id, String>();
        Map<Id, String>  testField2 = new Map<Id, String>();
        Map<Id, String> testField3 = new Map<Id, String>();
        
        Map<Id, Date> testField1 = new Map<Id, Date>();
        Map<Id, Date> testField2 = new Map<Id, Date>();
        Map<Id, Date> testField3 = new Map<Id, Date>();
        
        Set<String> testField1 = new Set<String>();
        Set<String> testField2 = new Set<String>();
        Set<String> testField3 = new Set<String>();
        
        List<testField1__c> testField1 = new List<test1__c>();
        List<testField2__c> testField2 = new List<test2__c>();
        List<Opportunity> oppList = new List<Opportunity>();
        
        for(TEstLogic__c logic : LogicLst) {
            if(logic.test!=null) {
                testField1__c.put(logic.Destination_testField1__c, logic.Api__c);
               testField1__c.put(logic.Destination_Milestone__c, logic.Date__c);
                testField1__c.add(logic.Api__c);
            }
            
            if(logic.Destination_testField2__c!=null) {
                pickupIdvField.put(logic.Destination_testField2__c, logic.Api__c);
                pickupIdvDate.put(logic.Destination_testField2__c, logic.Date__c);
                pickupFields.add(logic.Api__c);
            }
            
            if(logic.Opportunity__c!=null) {
                oppIdvField.put(logic.Opportunity__c, logic.Api__c);
                oppIdvDate.put(logic.Opportunity__c, logic.Date__c);
                oppFields.add(logic.Api__c);
            }
        }
        
        
        if(testField1.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(testField1__c>);
            String cols = string.join(fields,',');
            Set<Id> keys = testField1__c>.keyset();
            String query = 'Select Id, ' + cols + ' From testField1__c> Where Id IN : keys';
            
           testField1List = Database.query(query);
        }
        
        if( testField2.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll( testField2);
            String cols = string.join(fields,',');
            Set<Id> keys =  testField2.keyset();
            String query = 'Select Id, ' + cols + ' From  testField2 Where Id IN : keys';
            
            testField1 = Database.query(query);
        }
        
        if(testField3.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(testField1);
            String cols = string.join(fields,',');
            Set<Id> keys = testField3.keyset();
            String query = 'Select Id, ' + cols + ' From Opportunity Where Id IN : keys';
          
            oppList = Database.query(query);
        }
        
        for( testField1 m : testField1list){
           
            System.debug('#6. Calculated Date -> ' + testField1.get(m.Id));
            m.put(testField1.get(m.Id),testField1.get(m.Id));
        }
        
        for( testField2 p : testFieldlist){
           
            p.put(testField2.get(p.Id), testField2.get(p.Id));
        }
        
        for( Opportunity o : oppList){
           
            o.put(oppIdvField.get(o.Id), oppIdvDate.get(o.Id));
        }
        
        update testField1;
        update testField2;
        update oppList;
        
       
    }
}
Hi all,

plz help me to write test class for this code
public class DateMathHelper {
    public static Integer dateMathCounter = 0;
    public static Integer dateMathLogicCounter = 0;
    
    public void calculateDateMath(List<Epix_Date_Math__c> dateMathList) {
        Set<Id> logicIds = new Set<Id>();
        
        for(Epix_Date_Math__c math : dateMathList) {		
            logicIds.add(math.Epix_Date_Math_Logic__c);
        }
        
        System.debug('DateMathHelper#1. logicIds -> ' + logicIds);
        
        AggregateResult [] mathAggregate = [Select Epix_Date_Math_Logic__c, MIN(Calculated_Date__c) Earliest, MAX(Calculated_Date__c) Latest
                                            from Epix_Date_Math__c Where Epix_Date_Math_Logic__c IN :logicIds Group BY Epix_Date_Math_Logic__c];
        
        System.debug('DateMathHelper#2. mathAggregate -> ' + mathAggregate);
        
        Map<Id, Epix_Date_Math_Logic__c> logicMap = new Map<Id, Epix_Date_Math_Logic__c>([Select Id, Logic__c, Calculated_Date__c from Epix_Date_Math_Logic__c Where ID IN :logicIds]);
        
        List<Epix_Date_Math_Logic__c> logicToUpdate = new List<Epix_Date_Math_Logic__c>();
        
        System.debug('DateMathHelper#3. logicMap -> ' + logicMap);
        System.debug('DateMathHelper#2. mathAggregate -> ' + mathAggregate);
        Set<Id> tdblogicIDs = new Set<Id>();
        // Gettig TBD records to calculate min Earliest date---------
        for(Epix_Date_Math__c M : [Select Epix_Date_Math_Logic__c from Epix_Date_Math__c Where Epix_Date_Math_Logic__c IN :logicIds and Calculated_Date__c = null])
        {
            tdblogicIDs.add(M.Epix_Date_Math_Logic__c);
        }
        
        for (AggregateResult ar : mathAggregate) {
            String logicId = (String)ar.get('Epix_Date_Math_Logic__c');
            if(logicMap.containsKey(logicId)){
                Epix_Date_Math_Logic__c logic = logicMap.get(logicId);   
                
                if(logic.Logic__c == 'Earliest Of' || logic.Logic__c == 'Equals')
                {
                    if(tdblogicIDs.contains(logicId)){
                        logic.Calculated_Date__c = null;
                    }else {
                    	logic.Calculated_Date__c = (Date)ar.get('Earliest');
                    }
                }else if(logic.Logic__c == 'Latest Of')
                    logic.Calculated_Date__c = (Date)ar.get('Latest');
                
                logicToUpdate.add(logic);
            }        
        }
        
        System.debug('DateMathHelper#4. logicToUpdate After -> ' + logicToUpdate);
        
        update logicToUpdate; 
    }
    
    public void updateDateMathLogic(List<Epix_Date_Math_Logic__c> dateLogicList) {
        System.debug('updateDateMathLogic -> ');
        Map<Id, String> milestoneIdvField = new Map<Id, String>();
        Map<Id, String> pickupIdvField = new Map<Id, String>();
        Map<Id, String> oppIdvField = new Map<Id, String>();
        
        Map<Id, Date> milestoneIdvDate = new Map<Id, Date>();
        Map<Id, Date> pickupIdvDate = new Map<Id, Date>();
        Map<Id, Date> oppIdvDate = new Map<Id, Date>();
        
        Set<String> milestoneFields = new Set<String>();
        Set<String> pickupFields = new Set<String>();
        Set<String> oppFields = new Set<String>();
        
        List<Milestone__c> mileStoneList = new List<Milestone__c>();
        List<Pickup_Options__c> pickupList = new List<Pickup_Options__c>();
        List<Opportunity> oppList = new List<Opportunity>();
        
        for(Epix_Date_Math_Logic__c logic : dateLogicList) {
            if(logic.Destination_Milestone__c!=null) {
                milestoneIdvField.put(logic.Destination_Milestone__c, logic.Column_Api__c);
                milestoneIdvDate.put(logic.Destination_Milestone__c, logic.Calculated_Date__c);
                milestoneFields.add(logic.Column_Api__c);
            }
            
            if(logic.Destination_Pickup_Option__c!=null) {
                pickupIdvField.put(logic.Destination_Pickup_Option__c, logic.Column_Api__c);
                pickupIdvDate.put(logic.Destination_Pickup_Option__c, logic.Calculated_Date__c);
                pickupFields.add(logic.Column_Api__c);
            }
            
            if(logic.Destination_Opportunity__c!=null) {
                oppIdvField.put(logic.Destination_Opportunity__c, logic.Column_Api__c);
                oppIdvDate.put(logic.Destination_Opportunity__c, logic.Calculated_Date__c);
                oppFields.add(logic.Column_Api__c);
            }
        }
        
        System.debug('DateMathLogic   milestoneIdvField -> ' + milestoneIdvField);
        System.debug('DateMathLogic   pickupIdvField -> ' + pickupIdvField);
        System.debug('DateMathLogic   oppIdvField -> ' + oppIdvField);
        
        System.debug('DateMathLogic   milestoneIdvDate -> ' + milestoneIdvDate);
        System.debug('DateMathLogic   pickupIdvDate -> ' + pickupIdvDate);
        System.debug('DateMathLogic   oppIdvDate -> ' + oppIdvDate);
        
        if(milestoneIdvField.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(milestoneFields);
            String cols = string.join(fields,',');
            Set<Id> keys = milestoneIdvField.keyset();
            String query = 'Select Id, ' + cols + ' From Milestone__c Where Id IN : keys';
            System.debug('DateMathLogic#1.  MileStone query -> ' + query);
            mileStoneList = Database.query(query);
        }
        
        if(pickupIdvField.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(pickupFields);
            String cols = string.join(fields,',');
            Set<Id> keys = pickupIdvField.keyset();
            String query = 'Select Id, ' + cols + ' From Pickup_Options__c Where Id IN : keys';
            System.debug('DateMathLogic#2.  Pickup query -> ' + query);
            pickupList = Database.query(query);
        }
        
        if(oppIdvField.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(oppFields);
            String cols = string.join(fields,',');
            Set<Id> keys = oppIdvField.keyset();
            String query = 'Select Id, ' + cols + ' From Opportunity Where Id IN : keys';
            System.debug('DateMathLogic#3.  Opportunity query -> ' + query);
            oppList = Database.query(query);
        }
        
        for( Milestone__c m : mileStoneList){
            System.debug('#4. MileStone -> ' + m);
            System.debug('#5. Field -> ' + milestoneIdvField.get(m.Id));
            System.debug('#6. Calculated Date -> ' + milestoneIdvDate.get(m.Id));
            m.put(milestoneIdvField.get(m.Id), milestoneIdvDate.get(m.Id));
        }
        
        for( Pickup_Options__c p : pickupList){
            System.debug('#7. Pickup -> ' + p);
            System.debug('#8. Field -> ' + pickupIdvField.get(p.Id));
            System.debug('#9. Calculated Date -> ' + pickupIdvDate.get(p.Id));
            p.put(pickupIdvField.get(p.Id), pickupIdvDate.get(p.Id));
        }
        
        for( Opportunity o : oppList){
            System.debug('#10. Intellect Property -> ' + o);
            System.debug('#11. Field -> ' + oppIdvField.get(o.Id));
            System.debug('#12. Calculated Date -> ' + oppIdvDate.get(o.Id));
            o.put(oppIdvField.get(o.Id), oppIdvDate.get(o.Id));
        }
        
        update mileStoneList;
        update pickupList;
        update oppList;
        
        System.debug('<-- updateDateMathLogic');
    }
}

 
Hi all,
I want to display pi chart component on parent component to show opprtunity stages but below code is not working plz ihelp me its urgent
 
*********Apex class*********


public class LinechartController {
@AuraEnabled
    public static String getOpportunityJSON(){
 
       List<opportunity> lstopp = [SELECT Id, stagename FROM opportunity ];
        Map<String,Integer> mapLeadSource = new Map<String,Integer>();
 
        for(opportunity l : lstopp)
        {
            if(mapLeadSource.containsKey(l.stagename))
            {
                mapLeadSource.put(l.stagename, mapLeadSource.get(l.stagename)+1) ;
            }else{
                mapLeadSource.put(l.stagename, 0) ;
            }
        }
        system.debug('map values--'+mapLeadSource);
        list<RadarDataWrapper> radarData = new list<RadarDataWrapper>();
 
        for(String key : mapLeadSource.keySet())
        {
           RadarDataWrapper rdw = new RadarDataWrapper();
            rdw.name=key;
            rdw.y=mapLeadSource.get(key);
            radarData.add(rdw);
        }
        system.debug('rdw---'+radarData);
        return System.json.serialize(radarData);
        //return null;
    }
 
    /**
* Wrapper class to serialize as JSON as return Value
     * */
    class RadarDataWrapper
    {
       @AuraEnabled
       public String name;
       @AuraEnabled
       public integer y;
 
    }
 
}
 
<aura:component controller="LinechartController">
    <ltng:require scripts="{!join(',',$Resource.Highcharts,
                           $Resource.highchart3d,
                           $Resource.Highchartsexport
                           )}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
    
  
    <aura:attribute name="chartType" type="string"/>
    <aura:attribute name="chartTitle" type="string" default="Opportunity by StageName"/>
    <aura:attribute name="chartSubTitle" type="string" default="Display Opportunity Count by StageName"/>
    <aura:attribute name="xAxisCategories" type="string[]" default="['Qualification','Negotiation/Review','Closed Won','Id. Decision Makers','Proposal/Price Quote','Proposition','Prospecting','Perception Analysis','Needs Analysis']"/>
    <aura:attribute name="yAxisParameter" type="string" default="No. of Opportunity"/>
    <aura:attribute name="data" type="string"/>
    
    
    
    <div class="slds-card">
        <br/>
        <center><b><h1 class="slds-page-header__title slds-truncate slds-align-middle">
            Graphical Representaion of Opportunity Vs StageName</h1></b></center>
        <br/>
        <div class="slds-grid slds-wrap slds-grid--pull-padded">
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="chart" style="height: 400px"></div>
            </div>
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="linechart" style="height: 400px"></div>
            </div>
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="donutchart" style="height: 400px"></div>
            </div>
        </div>
    </div>
</aura:component>
 
****************Js Controller************
({
    afterScriptsLoaded : function(component, event, helper)
    {
        helper.doInit(component,event,helper);
    }    
 
})
 
**********Helper******************

({
    doInit : function(component, event, helper)
    {
        var action = component.get("c.getOpportunityJSON");
        action.setCallback(this, function(response) {
            var state = response.getState();
            //alert(state);
            if (state === "SUCCESS") {
                var dataObj= response.getReturnValue();
                //jsonData = dataObj;
                console.log('===='+dataObj);
                component.set("v.data",dataObj);
                helper.piechart(component,event,helper);
                helper.Linechart(component,event,helper);
                helper.donutchart(component,event,helper);
            }
        });
        $A.enqueueAction(action);
    },
    piechart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                renderTo: component.find("chart").getElement(),
                type: 'pie'
            },
            title: {
                text: component.get("v.chartTitle")+' (Pie Chart)'
            },
subtitle: {
                text: component.get("v.chartSubTitle")
            },
            xAxis: {
                categories: component.get("v.xAxisCategories"),
                crosshair: true
            },
            yAxis: {
                min: 0,
                title:
                {
                    text: component.get("v.yAxisParameter")
                }
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.y}</b>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        format: '<b>{point.name}</b>: {point.y} ',
                        style: {
                            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                        }
                    }
                }
            },
            series: [{
                name:'StageName',
                data:dataObj
            }]
 });
 
    },
 
    Linechart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                renderTo: component.find("linechart").getElement(),
                type: 'line'
            },
            title: {
                text: component.get("v.chartTitle")+' (Line Chart)'
            },
            subtitle: {
                text: component.get("v.chartSubTitle")
            },
            xAxis: {
                categories: component.get("v.xAxisCategories"),
                crosshair: true
            },
            yAxis: {
                min: 0,
                title:
                {
                    text: component.get("v.yAxisParameter")
                }
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.y}</b>'
            },
            plotOptions: {
                line: {
                    dataLabels: {
                        enabled: true
                    },
                    enableMouseTracking: false
                }
            },
            series: [{
                name:'StageName',
                data:dataObj
            }]
 
        });
 
    },
    donutchart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                renderTo: component.find("donutchart").getElement(),
                type: 'pie',
                options3d: {
                    enabled: true,
                    alpha: 45
                }
            },
            title: {
                text: component.get("v.chartTitle")+' (Donut Chart)'
            },
            subtitle: {
                text: component.get("v.chartSubTitle")
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
            },
            plotOptions: {
                pie: {
                    innerSize: 100,
                    depth: 45
                }
            },
            series: [{
                type: 'pie',
                name:'StageName',
                data:dataObj
            }]
 
        });
 
    }
})

 
Hi All,

I want to create pi chart componant in parent component to show opportunity stage count but pi chart component nit visble in lightning page plz help.

here is code
public class OppPieChartController {
    
@AuraEnabled
    public static String getOpportunityJSON(){
 
       List<opportunity> lstopp = [SELECT Id, stagename FROM opportunity ];
        Map<String,Integer> mapLeadSource = new Map<String,Integer>();
 
        for(opportunity l : lstopp)
        {
            if(mapLeadSource.containsKey(l.stagename))
            {
                mapLeadSource.put(l.stagename, mapLeadSource.get(l.stagename)+1) ;
            }else{
                mapLeadSource.put(l.stagename, 0) ;
            }
        }
        system.debug('map values--'+mapLeadSource);
        list<RadarDataWrapper> radarData = new list<RadarDataWrapper>();
 
        for(String key : mapLeadSource.keySet())
        {
           RadarDataWrapper rdw = new RadarDataWrapper();
            rdw.name=key;
            rdw.y=mapLeadSource.get(key);
            radarData.add(rdw);
        }
        system.debug('rdw---'+radarData);
        return System.json.serialize(radarData);
        //return null;
    }
 
    /**
* Wrapper class to serialize as JSON as return Value
     * */
    class RadarDataWrapper
    {
       @AuraEnabled
       public String name;
       @AuraEnabled
       public integer y;
 
    }
 
}
// component
<aura:component controller="OppPieChartController" implements="force:appHostable,
                                                               flexipage:availableForAllPageTypes,
                                                               flexipage:availableForRecordHome,force:hasRecordId,
                                                               forceCommunity:availableForAllPageTypes,
                                                               force:lightningQuickAction" access="global" >
    
    
   <ltng:require scripts="{!join(',',$Resource.Highcharts,
                           $Resource.highchart3d,
                           $Resource.Highchartsexport
                           )}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
    
  
    <aura:attribute name="chartType" type="string"/>
    <aura:attribute name="chartTitle" type="string" default="Opportunity by StageName"/>
    <aura:attribute name="chartSubTitle" type="string" default="Display Opportunity Count by StageName"/>
    <aura:attribute name="xAxisCategories" type="string[]" default="['Qualification','Negotiation/Review','Closed Won','Id. Decision Makers','Proposal/Price Quote','Proposition','Prospecting','Perception Analysis','Needs Analysis']"/>
    <aura:attribute name="yAxisParameter" type="string" default="No. of Opportunity"/>
    <aura:attribute name="data" type="string"/>
    
    
    
    <div class="slds-card">
        <br/>
        <center><b><h1 class="slds-page-header__title slds-truncate slds-align-middle">
            Graphical Representaion of Opportunity Vs StageName</h1></b></center>
        <br/>
        <div class="slds-grid slds-wrap slds-grid--pull-padded">
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="chart" style="height: 400px"></div>
            </div>
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="linechart" style="height: 400px"></div>
            </div>
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="donutchart" style="height: 400px"></div>
            </div>
        </div>
    </div>
</aura:component>
// JS File
 
({
    afterScriptsLoaded : function(component, event, helper)
    {
        helper.doInit(component,event,helper);
    }    
 
})

//Helper
({
    doInit : function(component, event, helper)
    {
        var action = component.get("c.getOpportunityJSON");
        action.setCallback(this, function(response) {
            var state = response.getState();
            //alert(state);
            if (state === "SUCCESS") {
                var dataObj= response.getReturnValue();
                //jsonData = dataObj;
                console.log('===='+dataObj);
                component.set("v.data",dataObj);
                helper.piechart(component,event,helper);
                helper.Linechart(component,event,helper);
                helper.donutchart(component,event,helper);
            }
        });
        $A.enqueueAction(action);
    },
    piechart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                renderTo: component.find("chart").getElement(),
                type: 'pie'
            },
            title: {
                text: component.get("v.chartTitle")+' (Pie Chart)'
            },
subtitle: {
                text: component.get("v.chartSubTitle")
            },
            xAxis: {
                categories: component.get("v.xAxisCategories"),
                crosshair: true
            },
            yAxis: {
                min: 0,
                title:
                {
                    text: component.get("v.yAxisParameter")
                }
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.y}</b>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        format: '<b>{point.name}</b>: {point.y} ',
                        style: {
                            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                        }
                    }
                }
            },
            series: [{
                name:'StageName',
                data:dataObj
            }]
 });
 
    },
 
    Linechart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                renderTo: component.find("linechart").getElement(),
                type: 'line'
            },
            title: {
                text: component.get("v.chartTitle")+' (Line Chart)'
            },
            subtitle: {
                text: component.get("v.chartSubTitle")
            },
            xAxis: {
                categories: component.get("v.xAxisCategories"),
                crosshair: true
            },
            yAxis: {
                min: 0,
                title:
                {
                    text: component.get("v.yAxisParameter")
                }
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.y}</b>'
            },
            plotOptions: {
                line: {
                    dataLabels: {
                        enabled: true
                    },
                    enableMouseTracking: false
                }
            },
            series: [{
                name:'StageName',
                data:dataObj
            }]
 
        });
 
    },
    donutchart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                renderTo: component.find("donutchart").getElement(),
                type: 'pie',
                options3d: {
                    enabled: true,
                    alpha: 45
                }
            },
            title: {
                text: component.get("v.chartTitle")+' (Donut Chart)'
            },
            subtitle: {
                text: component.get("v.chartSubTitle")
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
            },
            plotOptions: {
                pie: {
                    innerSize: 100,
                    depth: 45
                }
            },
            series: [{
                type: 'pie',
                name:'StageName',
                data:dataObj
            }]
 
        });
 
    }
})

​​​​​​​



 
Hi,
Here is my script written in anonymous window to create record against opportuniyt for 3 month jan,feb,march but its not working please help me to solve




Map <Id, Opportunity> oppItems = new Map <Id, Opportunity>();
        
    list<ARRCalcualateOpportunity__c> Arropplist= new list<ARRCalcualateOpportunity__c>();
        list<Opportunity> opplist= new list<Opportunity>();
        
    for(opportunity opp:opplist){
       if (opp.StageName == 'Closed Won'&& opp.closeDate.month() >=1 && opp.closeDate.month() <=3 ) 
        {
          oppItems.put(opp.Id, opp);
        }
    }
    
    List<OpportunityLineItem> oliList = [select Id, Name, Product2Id, Product2.Family,opportunity.amount,opportunity.closedate from 
                                         OpportunityLineItem where OpportunityId IN:oppItems.keyset()];
        
        system.debug('oli'+ oliList);
        for(OpportunityLineItem oli :oliList)
        {
             for(Integer i =1;i<=12;i++)
                     {
                         if(oli.product2.family == 'software Recurring')
            {
              ARRCalcualateOpportunity__c arrOpp = new ARRCalcualateOpportunity__c();
             
                 arropp.name=string.valueOf(oli.opportunity.closedate);
                arropp.OpportunityArr__c= oli.OpportunityId;      
                arrOpp.Opportunity_Product__c= oli.product2Id;
                system.debug('arropp'+arropp);
              Arropplist.add(arropp);
            }
        }
        }
        
        if(Arropplist.size() >0){
          insert Arropplist;
            System.debug('arropp list'+arropplist);
        }
    
             


            
                 

                    
                    
HI All,

Here is another script tried to insert 3 related record for opprtunity for 3 month (Jan,feb,March). But not working can anyone help please.
Script
Map <Id, Opportunity> oppItems = new Map <Id, Opportunity>();
       
    list<ARRCalcualateOpportunity__c> Arropplist= new list<ARRCalcualateOpportunity__c>();
        list<Opportunity> opplist= new list<Opportunity>();
    for(opportunity opp:opplist){
       if (opp.StageName == 'Closed Won'&& opp.closeDate.month() >=1 && opp.closeDate.month() <=3 ) 
        {
          oppItems.put(opp.Id, opp);
        }
    }
    
    List<OpportunityLineItem> oliList = [select Id, Name, Product2Id, Product2.Family from 
                                         OpportunityLineItem where OpportunityId IN:oppItems.keyset()];
        
        for(OpportunityLineItem oli :oliList)
        {
             

            if(oli.product2.family == 'software Recurring__c')
                 
                //Date dt = oppobj.closedate;
                    
                     for(Integer i =1;i<=12;i++)
            {
              ARRCalcualateOpportunity__c arrOpp = new ARRCalcualateOpportunity__c();
              arropp.name = oppItems.get(oli.OpportunityId).Name;
              arropp.ownerId = oppItems.get(oli.OpportunityId).OwnerId; 
              arropp.OpportunityArr__c=oppItems.get(oli.OpportunityId).Id;  
                System.debug('arropp list'+arropp);
              Arropplist.add(arropp);
               System.debug('arropp list'+arropplist);
            }
        }
        
        if(Arropplist.size() >0){
          insert Arropplist;
        }
    

 
Hi all,

Here is script to create related record for opprtunity for month jan,feb,march but its not working. please help me to solve it.


//Script
MapId, Opportunity oppItems = new MapId, Opportunity();
    listARRCalcualateOpportunity__c Arropplist= new listARRCalcualateOpportunity__c();
    for(opportunity oppTrigger.New){
        if(opp.StageName == 'closed Won')  
        {
          oppItems.put(opp.Id, opp);
        }
    }
    
    ListOpportunityLineItem oliList = [select Id,Name,Product2Id,Product2.Family from 
                                 OpportunityLineItem where OpportunityId IN  oppItems.keySet()];
        
        for(OpportunityLineItem oli  oliList){
            if(oli.product2.family == 'software Recurring__c')
            {
              ARRCalcualateOpportunity__c arrOpp = new ARRCalcualateOpportunity__c();
              arropp.name = oppItems.get(oli.OpportunityId).Name;
              arropp.ownerId = oppItems.get(oli.OpportunityId).OwnerId; 
              arropp.OpportunityArr__c=oppItems.get(oli.OpportunityId).Id;   
              Arropplist.add(arropp);
            }
        }
        
        if(Arropplist.size()  0){
          insert Arropplist;
        }
    }
}
Hi all,
Here is my script to update opprtunity record on reled object for 3 month but its not creating record plz help me

script


 list<opportunity> opplist  =new list <opportunity>();  
 List <ARRCalcualateOpportunity__c> ArroppList = new List <ARRCalcualateOpportunity__c>();
    for (Opportunity oppobj : opplist) 
    {
       
        if (oppobj.StageName == 'Closed Won' && oppobj.closedate.month()>=1 && oppobj.closedate.month<=3)
        {  
            for(OpportunityLineItem Oli:[select Id,Name,Product2Id,Product2.Family from
                                         OpportunityLineItem where OpportunityId=:oppobj.Id])
            {
                
                 if(oli.Product2.Family =='Software Recurring')
                     
                 {
                     // To display date in asscending order
                   Date dt = oppobj.closedate;
                     for(Integer i =0;i<12;i++)
                    {
                        ARRCalcualateOpportunity__c arrObj = new ARRCalcualateOpportunity__c(); 
                      arrobj.ARRdate__c = oppobj.CloseDate;
                        //will display 12 date in ascending order
                     arrobj.ARRdate__c  =dt.addMonths(i);
                       arrobj.Name = oppobj.name;
                        arrobj.oppAmount__c = oppobj.Amount;
           List<OpportunityLineItem> oppli= [select Id from OpportunityLineItem 
                                              where OpportunityId = : oppobj.Id];
                       
                        arrobj.Opportunity_Product__c = oppli[0].id;
                       arrobj.OpportunityArr__c= oppobj.Id;                        
                        ArroppList.add(arrobj);
                        
                    }
                         
                   }   
            }
        }
    
    }
if(arropplist>0){

 insert ArroppList;
}
   
 
Hi all, I want to Write a script for Inserting Records for Month Jan, Feb and March on opportunity related object can anyone help me to write this one. Since I never write script before.
Hi all,
Here is my trigger and trigger handler on opprtunity and test class.
In test class i am facing error as "Method does not exist or incorrect signature: void UpdateArrOPP(List<SObject>, Map<Id,SObject>) from the type opportunityArrTriggerHandler"
can anyone help me sort out this.

////Trigger
Trigger ArrOpptrigger on Opportunity (after update) {

if(trigger.isUpdate){
    if(trigger.isAfter)
{
if(!PreventOppArrRecurssion.firstcall){

PreventOppArrRecurssion.firstcall =false;

opportunityArrTriggerHandler.UpdateArrOPP(trigger.new,trigger.oldmap);
}
}
}
}

///Handler class

public class opportunityArrTriggerHandler {


    public static void UpdateArrOPP(list<opportunity>opplist,map<Id,Opportunity>oldoppmap)
    
  {
     
 List <ARRCalcualateOpportunity__c> ArroppList = new List <ARRCalcualateOpportunity__c>();
    for (Opportunity oppobj : opplist) 
    {
       
        if (oppobj.StageName == 'Closed Won')
        {  
            for(OpportunityLineItem Oli:[select Id,Name,Product2Id,Product2.Family from
                                         OpportunityLineItem where OpportunityId=:oppobj.Id])
            {
                
                 if(oli.Product2.Family =='Software Recurring')
                     
                 {
                     // To display date in asscending order
                   Date dt = oppobj.closedate;
                     for(Integer i =0;i<12;i++)
                    {
                        ARRCalcualateOpportunity__c arrObj = new ARRCalcualateOpportunity__c(); 
                      arrobj.ARRdate__c = oppobj.CloseDate;
                        //will display 12 date in ascending order
                     arrobj.ARRdate__c  =dt.addMonths(i);
                       arrobj.Name = oppobj.name;
                        arrobj.oppAmount__c = oppobj.Amount;
           List<OpportunityLineItem> oppli= [select Id from OpportunityLineItem 
                                                         where OpportunityId = : oppobj.Id];
                        arrobj.Opportunity_Product__c = oppli[0].id;
                       arrobj.OpportunityArr__c= oppobj.Id;                        
                        ArroppList.add(arrobj);
                        
                    }
                         
                   }   
            }
        }
    
    }
 insert ArroppList;
   }
}
///Test class

@isTest
public class OpportunityTriggerHnadlerTest1 {
    
        testmethod static void UpdateArrOPP1(){
           
          // set<string> SetOpportunityId = new set<string>();
          // date tempdte;
          list<Opportunity>oppList=new  list<Opportunity>();
           map<Id,Opportunity>oldoppmap= new map<Id,Opportunity>();
           Product2 prod = new Product2(Name = 'Anti-infectives 2007', Family = 'software Recurring', IsActive = true);
           insert prod;
            
           /*Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];
           insert standardPB;*/
           Pricebook2 standardPricebook = new Pricebook2(
            Id = Test.getStandardPricebookId(),
            IsActive = true);
        update standardPricebook;
        //System.debug('Pricebook'+standardPricebook);
           
           Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book', Description = 'Price Book 2009 Products', 
                                          IsActive = true);
           insert pb;
           
           PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = standardPricebook.Id, Product2Id = prod.Id,
                                                             UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert standardPrice;
           
           /*PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
           insert standardPrice;*/
                   
           Opportunity oppobj=new Opportunity();
           oppobj.Name='Testing Opportunity';
           oppobj.CloseDate=system.today();
           oppobj.StageName = 'Prospecting';
          // oppobj.IsClosed_won__c=true;
           
           //SetOpportunityId.add(oppobj.Id);
           insert oppobj;
           
           
           List<OpportunityLineItem> lstOppLineItem=new List<OpportunityLineItem>();
           OpportunityLineItem olli = new OpportunityLineItem (Quantity=2, OpportunityId=oppobj.Id, TotalPrice=10, PriceBookEntryId=standardPrice.Id); 
           lstOppLineItem.add(olli);
           insert lstOppLineItem;
           
           
          // tempdte = olli.Opportunity.CloseDate;
           oppobj.StageName='Closed Won';
           //oppobj.IsClosed_won__c=false;
           update oppobj;
           
          List <ARRCalcualateOpportunity__c> ArroppList = new List <ARRCalcualateOpportunity__c>();
           Date dt = oppobj.closedate;

           for(Integer i =0;i<12;i++){
               ARRCalcualateOpportunity__c arrObj = new ARRCalcualateOpportunity__c(); 
                      arrobj.ARRdate__c = oppobj.CloseDate;
               // obj.Name =String.valueOf(tempdte);
                   //objlist.add(obj);
                  arrobj.ARRdate__c  =dt.addMonths(i);
                       arrobj.Name = oppobj.name;
                        arrobj.oppAmount__c = oppobj.Amount;
           List<OpportunityLineItem> oppli= [select Id from OpportunityLineItem 
                                                         where OpportunityId = : oppobj.Id];
                        arrobj.Opportunity_Product__c = oppli[0].id;
                       arrobj.OpportunityArr__c= oppobj.Id;                        
                        ArroppList.add(arrobj);
                        
           }
           
           insert arropplist;
       
           Test.startTest();
           //TriggerHandler_opportunity closedTrigger=new TriggerHandler_opportunity();
           //TriggerHandler_opportunity.CreateRecord(setopportunityId);
         //  TriggerHandler_opportunity.updateopprecord(setopportunityId);
         PreventOppArrRecurssion.firstcall =false;

opportunityArrTriggerHandler.UpdateArrOPP(trigger.new,trigger.oldmap);
           Test.stopTest();
     }
}

 
Hi all, help me to write test class
public class myjob 
{
@AuraEnabled(cacheable=true)
    Public static List<Job_Requirement__c> myservice()
    {
        list<Job_Requirement__c> lstjob = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Standard'];
        return lstjob;
    }

@AuraEnabled(cacheable=true)
    Public static List<Job_Requirement__c> myservicegeneral()
    {
        list<Job_Requirement__c> lstjobgeneral = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Specialty'];
        return lstjobgeneral;
    }
    @AuraEnabled(cacheable=true)
    Public static List<Job_Requirement__c> myservicinteriror()
    {
        list<Job_Requirement__c> lstjobinteriror = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Custom Named'];
        return lstjobinteriror;
    }

    @AuraEnabled(cacheable=false)
    Public static List<Job_Requirement__c> getStandardWorkOrders()
    {
        list<Job_Requirement__c> lstjob = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c ];
                                          //Type__c='Standard'];
        return lstjob;
    }

    Public static List<Job_Requirement__c> getSpecialityWokOrders()
    {
        list<Job_Requirement__c> lstjobgeneral = [select id, Name, Service_Name__c, Type__c from Job_Requirement__c where
                                          Type__c='Specialty'];
        return lstjobgeneral;
    }
}
HI all,
There is one field i.e. work order which is not feching data from ui please tell me resson below is my code
// apex class

public with sharing class ProjectLineItemHelper

  {
    @AuraEnabled(cacheable=true)
      public static List<Project_Line_Items__c> getprojectlineItemList(id projectId) {
       system.debug('prjId >> ' + projectId);
        return[SELECT Id, Name, Area_Of_House__c, QTY_Type__c, qty__c, Rate__c, total__c,Line_Item_Status__c,Projects__c,Master_Line_Items_List__r.name,
        Project_Work_Order__r.name,Decription__c FROM Project_Line_Items__c where Projects__c=:projectId];
            
             }
          /*   @AuraEnabled(cacheable=true)
      public static List<Project_Line_Items__c> getprojectlineItemWorkOrderList(id projectId) {
       system.debug('prjId >> ' + projectId);
        return[SELECT Id, Name, Area_Of_House__c, QTY_Type__c, qty__c, Rate__c, total__c,Line_Item_Status__c,Projects__c,Master_Line_Items_List__r.name,
        Project_Work_Order__r.name,Decription__c FROM Project_Line_Items__c where Projects__c=:projectId];
            
             }*/
      
      
}
 
// .js file

import { LightningElement ,api, wire, track} from 'lwc';
import getprojectlineItemList from '@salesforce/apex/ProjectLineItemHelper.getprojectlineItemList';
//import getprojectlineItemWorkOrderList from '@salesforce/apex/ProjectLineItemHelper.getprojectlineItemWorkOrderList';
export default class projectLineItemAddTable extends LightningElement {
     @api recordId;
    // @api recordid;

    @track columns = [{label: 'Work Order name',
            fieldName: ' Project_Work_Order__c',
            type: 'text',
            sortable: true

    },
        {
            label: 'Line Item name',
            fieldName: 'Name',
            type: 'text',
            sortable: true
        },
        {
            label: 'Description',
            fieldName: 'Decription__c',
           type : 'Text',
            sortable: true
        },
        {
            label: 'Area of House',
            fieldName: 'Area_Of_House__c',
          type: 'picklist',
            sortable: true
        },
       {
            label: 'Status',
            fieldName: 'Line_Item_Status__c',
           type: 'picklist',
            sortable: true
        },
        {
            label: 'Qty Type',
            fieldName: 'QTY_Type__c',
          type : 'picklist',
            sortable: true
        },
        {
            label: 'Qty',
            fieldName: 'QTY__c',
            type: 'text',
 	        sortable: true
        },
        {
            label: 'Rate',
            fieldName: 'Rate__c',
            type: 'currency',
            sortable: true
        },
	{
            label: 'Total',
            fieldName: 'Total__c',
           type : 'text',
            sortable: true
        },
        
    ];
 
    @track error;

    @track lineItemList ;
    //selectedWOName = '';



    //to filterline item  record using project id
    @wire(getprojectlineItemList, {projectId : '$recordId'})
    wiredProjectlineItems({
        error,
        data
    }) {
       
        if (data) {
            this.lineItemList = data;
        } else if (error) {
            this.error = error;
        }
    }

    connectedCallback(){
        console.log('project ID' + this.recordId);
    }
    // to filter work order
    /* @wire( getprojectlineItemWorkOrderList, {projectId : '$recordId'})
    wiredProjectlineItems({
        error,
        data
    }) {
       
        if (data) {
            this.lineItemList = data;
        } else if (error) {
            this.error = error;
        }
    }

    connectedCallback(){
        console.log('project ID' + this.recordId);
    }*/


}
 
//, Html
<template>
    <!--h1 font-size:60px> Project Line Items</h1-->
     <div class="slds-box slds-theme_default">
    <lightning-card>
      <h3 slot="title" class="slds-text-title_bold">
        <lightning-icon
          icon-name="standard:client"
          size="medium">
        </lightning-icon>
        <span class="slds-m-left_small">
          Project Line Items</span>
        
      </h3>
    <!-- <template if:true={lineItemList}> -->
        <lightning-datatable data={lineItemList} columns={columns} key-field="Id"  hide-checkbox-column="true" >
            
 
        </lightning-datatable>
    <!-- </template> -->
    
    <template if:true={error}>
        {error}
    </template>
    </lightning-card>
    </div>
</template>


 
Hi all,
I am new to integration & I want to perform integration using swagger ui,
I want to transper swagger ui id to affiliateId. can anyone help me to solve that one its urgent.
The manditory fields using swagger for integration are
affiliateIntegrationId integer($int32)
affiliateId* integer($int32)
affiliateIntegrationCode* string
affiliateStatus* string
affiliateIntegrationType* string 
HI all, 
I amm beginner in apex so please help me to write test class for below handler class
*********Write test class for below class***********


public class TestHelper {
    public static Integer TestCounter1 = 0;
    public static Integer TestCounter2 = 0;
    
    public void DataTEst(List<TEst__c> objtest) {
        Set<Id> logicIds = new Set<Id>();
        
        for(TEst__c te : objtes) {		
            logicIds.add(te.TEstLogic__c);
        }
        
      
        
        AggregateResult [] TestAgg = [Select TEstLogic__c, MIN(Date__c) Earliest, MAX(Date__c) Latest
                                            from TEst__c Where TEstLogic__c IN :logicIds Group BY TEstLogic__c];
        
      
        
        Map<Id, TEstLogic__c> logicMap = new Map<Id, TEstLogic__c>([Select Id, Logic__c, Date__c from TEstLogic__c Where ID IN :logicIds]);
        
        List<TEstLogic__c> logicToUpdate = new List<TEstLogic__c>();
        
        
        Set<Id> tdblogicIDs = new Set<Id>();
       
        for(Test__c M : [Select TEstLogic__c from test__c Where TEstLogic__c__c IN :logicIds and Date__c = null])
        {
            tdblogicIDs.add(M.Epix_Date_Math_Logic__c);
        }
        
        for (AggregateResult ar : mathAggregate) {
            String logicId = (String)ar.get('TEstLogic__c');
            if(logicMap.containsKey(logicId)){
                TEstLogic__c logic = logicMap.get(logicId);   
                
                if(logic.Logic__c == 'Earliest Of' || logic.Logic__c == 'Equals')
                {
                    if(tdblogicIDs.contains(logicId)){
                        logic.Date__c = null;
                    }else {
                    	logic.Date__c = (Date)ar.get('Earliest');
                    }
                }else if(logic.Logic__c == 'Latest Of')
                    logic.Date__c = (Date)ar.get('Latest');
                
                logicToUpdate.add(logic);
            }        
        }
        
       
        update logicToUpdate; 
    }
    
    public void updateDateMathLogic(List<TEstLogic__c> dateLogicList) {
        
        Map<Id, String> testField1  = new Map<Id, String>();
        Map<Id, String>  testField2 = new Map<Id, String>();
        Map<Id, String> testField3 = new Map<Id, String>();
        
        Map<Id, Date> testField1 = new Map<Id, Date>();
        Map<Id, Date> testField2 = new Map<Id, Date>();
        Map<Id, Date> testField3 = new Map<Id, Date>();
        
        Set<String> testField1 = new Set<String>();
        Set<String> testField2 = new Set<String>();
        Set<String> testField3 = new Set<String>();
        
        List<testField1__c> testField1 = new List<test1__c>();
        List<testField2__c> testField2 = new List<test2__c>();
        List<Opportunity> oppList = new List<Opportunity>();
        
        for(TEstLogic__c logic : LogicLst) {
            if(logic.test!=null) {
                testField1__c.put(logic.Destination_testField1__c, logic.Api__c);
               testField1__c.put(logic.Destination_Milestone__c, logic.Date__c);
                testField1__c.add(logic.Api__c);
            }
            
            if(logic.Destination_testField2__c!=null) {
                pickupIdvField.put(logic.Destination_testField2__c, logic.Api__c);
                pickupIdvDate.put(logic.Destination_testField2__c, logic.Date__c);
                pickupFields.add(logic.Api__c);
            }
            
            if(logic.Opportunity__c!=null) {
                oppIdvField.put(logic.Opportunity__c, logic.Api__c);
                oppIdvDate.put(logic.Opportunity__c, logic.Date__c);
                oppFields.add(logic.Api__c);
            }
        }
        
        
        if(testField1.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(testField1__c>);
            String cols = string.join(fields,',');
            Set<Id> keys = testField1__c>.keyset();
            String query = 'Select Id, ' + cols + ' From testField1__c> Where Id IN : keys';
            
           testField1List = Database.query(query);
        }
        
        if( testField2.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll( testField2);
            String cols = string.join(fields,',');
            Set<Id> keys =  testField2.keyset();
            String query = 'Select Id, ' + cols + ' From  testField2 Where Id IN : keys';
            
            testField1 = Database.query(query);
        }
        
        if(testField3.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(testField1);
            String cols = string.join(fields,',');
            Set<Id> keys = testField3.keyset();
            String query = 'Select Id, ' + cols + ' From Opportunity Where Id IN : keys';
          
            oppList = Database.query(query);
        }
        
        for( testField1 m : testField1list){
           
            System.debug('#6. Calculated Date -> ' + testField1.get(m.Id));
            m.put(testField1.get(m.Id),testField1.get(m.Id));
        }
        
        for( testField2 p : testFieldlist){
           
            p.put(testField2.get(p.Id), testField2.get(p.Id));
        }
        
        for( Opportunity o : oppList){
           
            o.put(oppIdvField.get(o.Id), oppIdvDate.get(o.Id));
        }
        
        update testField1;
        update testField2;
        update oppList;
        
       
    }
}
Hi all,

plz help me to write test class for this code
public class DateMathHelper {
    public static Integer dateMathCounter = 0;
    public static Integer dateMathLogicCounter = 0;
    
    public void calculateDateMath(List<Epix_Date_Math__c> dateMathList) {
        Set<Id> logicIds = new Set<Id>();
        
        for(Epix_Date_Math__c math : dateMathList) {		
            logicIds.add(math.Epix_Date_Math_Logic__c);
        }
        
        System.debug('DateMathHelper#1. logicIds -> ' + logicIds);
        
        AggregateResult [] mathAggregate = [Select Epix_Date_Math_Logic__c, MIN(Calculated_Date__c) Earliest, MAX(Calculated_Date__c) Latest
                                            from Epix_Date_Math__c Where Epix_Date_Math_Logic__c IN :logicIds Group BY Epix_Date_Math_Logic__c];
        
        System.debug('DateMathHelper#2. mathAggregate -> ' + mathAggregate);
        
        Map<Id, Epix_Date_Math_Logic__c> logicMap = new Map<Id, Epix_Date_Math_Logic__c>([Select Id, Logic__c, Calculated_Date__c from Epix_Date_Math_Logic__c Where ID IN :logicIds]);
        
        List<Epix_Date_Math_Logic__c> logicToUpdate = new List<Epix_Date_Math_Logic__c>();
        
        System.debug('DateMathHelper#3. logicMap -> ' + logicMap);
        System.debug('DateMathHelper#2. mathAggregate -> ' + mathAggregate);
        Set<Id> tdblogicIDs = new Set<Id>();
        // Gettig TBD records to calculate min Earliest date---------
        for(Epix_Date_Math__c M : [Select Epix_Date_Math_Logic__c from Epix_Date_Math__c Where Epix_Date_Math_Logic__c IN :logicIds and Calculated_Date__c = null])
        {
            tdblogicIDs.add(M.Epix_Date_Math_Logic__c);
        }
        
        for (AggregateResult ar : mathAggregate) {
            String logicId = (String)ar.get('Epix_Date_Math_Logic__c');
            if(logicMap.containsKey(logicId)){
                Epix_Date_Math_Logic__c logic = logicMap.get(logicId);   
                
                if(logic.Logic__c == 'Earliest Of' || logic.Logic__c == 'Equals')
                {
                    if(tdblogicIDs.contains(logicId)){
                        logic.Calculated_Date__c = null;
                    }else {
                    	logic.Calculated_Date__c = (Date)ar.get('Earliest');
                    }
                }else if(logic.Logic__c == 'Latest Of')
                    logic.Calculated_Date__c = (Date)ar.get('Latest');
                
                logicToUpdate.add(logic);
            }        
        }
        
        System.debug('DateMathHelper#4. logicToUpdate After -> ' + logicToUpdate);
        
        update logicToUpdate; 
    }
    
    public void updateDateMathLogic(List<Epix_Date_Math_Logic__c> dateLogicList) {
        System.debug('updateDateMathLogic -> ');
        Map<Id, String> milestoneIdvField = new Map<Id, String>();
        Map<Id, String> pickupIdvField = new Map<Id, String>();
        Map<Id, String> oppIdvField = new Map<Id, String>();
        
        Map<Id, Date> milestoneIdvDate = new Map<Id, Date>();
        Map<Id, Date> pickupIdvDate = new Map<Id, Date>();
        Map<Id, Date> oppIdvDate = new Map<Id, Date>();
        
        Set<String> milestoneFields = new Set<String>();
        Set<String> pickupFields = new Set<String>();
        Set<String> oppFields = new Set<String>();
        
        List<Milestone__c> mileStoneList = new List<Milestone__c>();
        List<Pickup_Options__c> pickupList = new List<Pickup_Options__c>();
        List<Opportunity> oppList = new List<Opportunity>();
        
        for(Epix_Date_Math_Logic__c logic : dateLogicList) {
            if(logic.Destination_Milestone__c!=null) {
                milestoneIdvField.put(logic.Destination_Milestone__c, logic.Column_Api__c);
                milestoneIdvDate.put(logic.Destination_Milestone__c, logic.Calculated_Date__c);
                milestoneFields.add(logic.Column_Api__c);
            }
            
            if(logic.Destination_Pickup_Option__c!=null) {
                pickupIdvField.put(logic.Destination_Pickup_Option__c, logic.Column_Api__c);
                pickupIdvDate.put(logic.Destination_Pickup_Option__c, logic.Calculated_Date__c);
                pickupFields.add(logic.Column_Api__c);
            }
            
            if(logic.Destination_Opportunity__c!=null) {
                oppIdvField.put(logic.Destination_Opportunity__c, logic.Column_Api__c);
                oppIdvDate.put(logic.Destination_Opportunity__c, logic.Calculated_Date__c);
                oppFields.add(logic.Column_Api__c);
            }
        }
        
        System.debug('DateMathLogic   milestoneIdvField -> ' + milestoneIdvField);
        System.debug('DateMathLogic   pickupIdvField -> ' + pickupIdvField);
        System.debug('DateMathLogic   oppIdvField -> ' + oppIdvField);
        
        System.debug('DateMathLogic   milestoneIdvDate -> ' + milestoneIdvDate);
        System.debug('DateMathLogic   pickupIdvDate -> ' + pickupIdvDate);
        System.debug('DateMathLogic   oppIdvDate -> ' + oppIdvDate);
        
        if(milestoneIdvField.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(milestoneFields);
            String cols = string.join(fields,',');
            Set<Id> keys = milestoneIdvField.keyset();
            String query = 'Select Id, ' + cols + ' From Milestone__c Where Id IN : keys';
            System.debug('DateMathLogic#1.  MileStone query -> ' + query);
            mileStoneList = Database.query(query);
        }
        
        if(pickupIdvField.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(pickupFields);
            String cols = string.join(fields,',');
            Set<Id> keys = pickupIdvField.keyset();
            String query = 'Select Id, ' + cols + ' From Pickup_Options__c Where Id IN : keys';
            System.debug('DateMathLogic#2.  Pickup query -> ' + query);
            pickupList = Database.query(query);
        }
        
        if(oppIdvField.size() > 0){
            List<String> fields = new List<String>();
            fields.addAll(oppFields);
            String cols = string.join(fields,',');
            Set<Id> keys = oppIdvField.keyset();
            String query = 'Select Id, ' + cols + ' From Opportunity Where Id IN : keys';
            System.debug('DateMathLogic#3.  Opportunity query -> ' + query);
            oppList = Database.query(query);
        }
        
        for( Milestone__c m : mileStoneList){
            System.debug('#4. MileStone -> ' + m);
            System.debug('#5. Field -> ' + milestoneIdvField.get(m.Id));
            System.debug('#6. Calculated Date -> ' + milestoneIdvDate.get(m.Id));
            m.put(milestoneIdvField.get(m.Id), milestoneIdvDate.get(m.Id));
        }
        
        for( Pickup_Options__c p : pickupList){
            System.debug('#7. Pickup -> ' + p);
            System.debug('#8. Field -> ' + pickupIdvField.get(p.Id));
            System.debug('#9. Calculated Date -> ' + pickupIdvDate.get(p.Id));
            p.put(pickupIdvField.get(p.Id), pickupIdvDate.get(p.Id));
        }
        
        for( Opportunity o : oppList){
            System.debug('#10. Intellect Property -> ' + o);
            System.debug('#11. Field -> ' + oppIdvField.get(o.Id));
            System.debug('#12. Calculated Date -> ' + oppIdvDate.get(o.Id));
            o.put(oppIdvField.get(o.Id), oppIdvDate.get(o.Id));
        }
        
        update mileStoneList;
        update pickupList;
        update oppList;
        
        System.debug('<-- updateDateMathLogic');
    }
}

 
Hi all,
I want to display pi chart component on parent component to show opprtunity stages but below code is not working plz ihelp me its urgent
 
*********Apex class*********


public class LinechartController {
@AuraEnabled
    public static String getOpportunityJSON(){
 
       List<opportunity> lstopp = [SELECT Id, stagename FROM opportunity ];
        Map<String,Integer> mapLeadSource = new Map<String,Integer>();
 
        for(opportunity l : lstopp)
        {
            if(mapLeadSource.containsKey(l.stagename))
            {
                mapLeadSource.put(l.stagename, mapLeadSource.get(l.stagename)+1) ;
            }else{
                mapLeadSource.put(l.stagename, 0) ;
            }
        }
        system.debug('map values--'+mapLeadSource);
        list<RadarDataWrapper> radarData = new list<RadarDataWrapper>();
 
        for(String key : mapLeadSource.keySet())
        {
           RadarDataWrapper rdw = new RadarDataWrapper();
            rdw.name=key;
            rdw.y=mapLeadSource.get(key);
            radarData.add(rdw);
        }
        system.debug('rdw---'+radarData);
        return System.json.serialize(radarData);
        //return null;
    }
 
    /**
* Wrapper class to serialize as JSON as return Value
     * */
    class RadarDataWrapper
    {
       @AuraEnabled
       public String name;
       @AuraEnabled
       public integer y;
 
    }
 
}
 
<aura:component controller="LinechartController">
    <ltng:require scripts="{!join(',',$Resource.Highcharts,
                           $Resource.highchart3d,
                           $Resource.Highchartsexport
                           )}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
    
  
    <aura:attribute name="chartType" type="string"/>
    <aura:attribute name="chartTitle" type="string" default="Opportunity by StageName"/>
    <aura:attribute name="chartSubTitle" type="string" default="Display Opportunity Count by StageName"/>
    <aura:attribute name="xAxisCategories" type="string[]" default="['Qualification','Negotiation/Review','Closed Won','Id. Decision Makers','Proposal/Price Quote','Proposition','Prospecting','Perception Analysis','Needs Analysis']"/>
    <aura:attribute name="yAxisParameter" type="string" default="No. of Opportunity"/>
    <aura:attribute name="data" type="string"/>
    
    
    
    <div class="slds-card">
        <br/>
        <center><b><h1 class="slds-page-header__title slds-truncate slds-align-middle">
            Graphical Representaion of Opportunity Vs StageName</h1></b></center>
        <br/>
        <div class="slds-grid slds-wrap slds-grid--pull-padded">
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="chart" style="height: 400px"></div>
            </div>
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="linechart" style="height: 400px"></div>
            </div>
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="donutchart" style="height: 400px"></div>
            </div>
        </div>
    </div>
</aura:component>
 
****************Js Controller************
({
    afterScriptsLoaded : function(component, event, helper)
    {
        helper.doInit(component,event,helper);
    }    
 
})
 
**********Helper******************

({
    doInit : function(component, event, helper)
    {
        var action = component.get("c.getOpportunityJSON");
        action.setCallback(this, function(response) {
            var state = response.getState();
            //alert(state);
            if (state === "SUCCESS") {
                var dataObj= response.getReturnValue();
                //jsonData = dataObj;
                console.log('===='+dataObj);
                component.set("v.data",dataObj);
                helper.piechart(component,event,helper);
                helper.Linechart(component,event,helper);
                helper.donutchart(component,event,helper);
            }
        });
        $A.enqueueAction(action);
    },
    piechart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                renderTo: component.find("chart").getElement(),
                type: 'pie'
            },
            title: {
                text: component.get("v.chartTitle")+' (Pie Chart)'
            },
subtitle: {
                text: component.get("v.chartSubTitle")
            },
            xAxis: {
                categories: component.get("v.xAxisCategories"),
                crosshair: true
            },
            yAxis: {
                min: 0,
                title:
                {
                    text: component.get("v.yAxisParameter")
                }
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.y}</b>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        format: '<b>{point.name}</b>: {point.y} ',
                        style: {
                            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                        }
                    }
                }
            },
            series: [{
                name:'StageName',
                data:dataObj
            }]
 });
 
    },
 
    Linechart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                renderTo: component.find("linechart").getElement(),
                type: 'line'
            },
            title: {
                text: component.get("v.chartTitle")+' (Line Chart)'
            },
            subtitle: {
                text: component.get("v.chartSubTitle")
            },
            xAxis: {
                categories: component.get("v.xAxisCategories"),
                crosshair: true
            },
            yAxis: {
                min: 0,
                title:
                {
                    text: component.get("v.yAxisParameter")
                }
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.y}</b>'
            },
            plotOptions: {
                line: {
                    dataLabels: {
                        enabled: true
                    },
                    enableMouseTracking: false
                }
            },
            series: [{
                name:'StageName',
                data:dataObj
            }]
 
        });
 
    },
    donutchart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                renderTo: component.find("donutchart").getElement(),
                type: 'pie',
                options3d: {
                    enabled: true,
                    alpha: 45
                }
            },
            title: {
                text: component.get("v.chartTitle")+' (Donut Chart)'
            },
            subtitle: {
                text: component.get("v.chartSubTitle")
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
            },
            plotOptions: {
                pie: {
                    innerSize: 100,
                    depth: 45
                }
            },
            series: [{
                type: 'pie',
                name:'StageName',
                data:dataObj
            }]
 
        });
 
    }
})

 
Hi All,

I want to create pi chart componant in parent component to show opportunity stage count but pi chart component nit visble in lightning page plz help.

here is code
public class OppPieChartController {
    
@AuraEnabled
    public static String getOpportunityJSON(){
 
       List<opportunity> lstopp = [SELECT Id, stagename FROM opportunity ];
        Map<String,Integer> mapLeadSource = new Map<String,Integer>();
 
        for(opportunity l : lstopp)
        {
            if(mapLeadSource.containsKey(l.stagename))
            {
                mapLeadSource.put(l.stagename, mapLeadSource.get(l.stagename)+1) ;
            }else{
                mapLeadSource.put(l.stagename, 0) ;
            }
        }
        system.debug('map values--'+mapLeadSource);
        list<RadarDataWrapper> radarData = new list<RadarDataWrapper>();
 
        for(String key : mapLeadSource.keySet())
        {
           RadarDataWrapper rdw = new RadarDataWrapper();
            rdw.name=key;
            rdw.y=mapLeadSource.get(key);
            radarData.add(rdw);
        }
        system.debug('rdw---'+radarData);
        return System.json.serialize(radarData);
        //return null;
    }
 
    /**
* Wrapper class to serialize as JSON as return Value
     * */
    class RadarDataWrapper
    {
       @AuraEnabled
       public String name;
       @AuraEnabled
       public integer y;
 
    }
 
}
// component
<aura:component controller="OppPieChartController" implements="force:appHostable,
                                                               flexipage:availableForAllPageTypes,
                                                               flexipage:availableForRecordHome,force:hasRecordId,
                                                               forceCommunity:availableForAllPageTypes,
                                                               force:lightningQuickAction" access="global" >
    
    
   <ltng:require scripts="{!join(',',$Resource.Highcharts,
                           $Resource.highchart3d,
                           $Resource.Highchartsexport
                           )}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
    
  
    <aura:attribute name="chartType" type="string"/>
    <aura:attribute name="chartTitle" type="string" default="Opportunity by StageName"/>
    <aura:attribute name="chartSubTitle" type="string" default="Display Opportunity Count by StageName"/>
    <aura:attribute name="xAxisCategories" type="string[]" default="['Qualification','Negotiation/Review','Closed Won','Id. Decision Makers','Proposal/Price Quote','Proposition','Prospecting','Perception Analysis','Needs Analysis']"/>
    <aura:attribute name="yAxisParameter" type="string" default="No. of Opportunity"/>
    <aura:attribute name="data" type="string"/>
    
    
    
    <div class="slds-card">
        <br/>
        <center><b><h1 class="slds-page-header__title slds-truncate slds-align-middle">
            Graphical Representaion of Opportunity Vs StageName</h1></b></center>
        <br/>
        <div class="slds-grid slds-wrap slds-grid--pull-padded">
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="chart" style="height: 400px"></div>
            </div>
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="linechart" style="height: 400px"></div>
            </div>
            <div class="slds-col--padded slds-size--1-of-2 slds-medium-size--2-of-6 slds-large-size--4-of-12 cusdiv">
                <div aura:id="donutchart" style="height: 400px"></div>
            </div>
        </div>
    </div>
</aura:component>
// JS File
 
({
    afterScriptsLoaded : function(component, event, helper)
    {
        helper.doInit(component,event,helper);
    }    
 
})

//Helper
({
    doInit : function(component, event, helper)
    {
        var action = component.get("c.getOpportunityJSON");
        action.setCallback(this, function(response) {
            var state = response.getState();
            //alert(state);
            if (state === "SUCCESS") {
                var dataObj= response.getReturnValue();
                //jsonData = dataObj;
                console.log('===='+dataObj);
                component.set("v.data",dataObj);
                helper.piechart(component,event,helper);
                helper.Linechart(component,event,helper);
                helper.donutchart(component,event,helper);
            }
        });
        $A.enqueueAction(action);
    },
    piechart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                renderTo: component.find("chart").getElement(),
                type: 'pie'
            },
            title: {
                text: component.get("v.chartTitle")+' (Pie Chart)'
            },
subtitle: {
                text: component.get("v.chartSubTitle")
            },
            xAxis: {
                categories: component.get("v.xAxisCategories"),
                crosshair: true
            },
            yAxis: {
                min: 0,
                title:
                {
                    text: component.get("v.yAxisParameter")
                }
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.y}</b>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        format: '<b>{point.name}</b>: {point.y} ',
                        style: {
                            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                        }
                    }
                }
            },
            series: [{
                name:'StageName',
                data:dataObj
            }]
 });
 
    },
 
    Linechart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false,
                renderTo: component.find("linechart").getElement(),
                type: 'line'
            },
            title: {
                text: component.get("v.chartTitle")+' (Line Chart)'
            },
            subtitle: {
                text: component.get("v.chartSubTitle")
            },
            xAxis: {
                categories: component.get("v.xAxisCategories"),
                crosshair: true
            },
            yAxis: {
                min: 0,
                title:
                {
                    text: component.get("v.yAxisParameter")
                }
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.y}</b>'
            },
            plotOptions: {
                line: {
                    dataLabels: {
                        enabled: true
                    },
                    enableMouseTracking: false
                }
            },
            series: [{
                name:'StageName',
                data:dataObj
            }]
 
        });
 
    },
    donutchart : function(component,event,helper) {
        var jsonData = component.get("v.data");
        var dataObj = JSON.parse(jsonData);
 
        new Highcharts.Chart({
            chart: {
                renderTo: component.find("donutchart").getElement(),
                type: 'pie',
                options3d: {
                    enabled: true,
                    alpha: 45
                }
            },
            title: {
                text: component.get("v.chartTitle")+' (Donut Chart)'
            },
            subtitle: {
                text: component.get("v.chartSubTitle")
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
            },
            plotOptions: {
                pie: {
                    innerSize: 100,
                    depth: 45
                }
            },
            series: [{
                type: 'pie',
                name:'StageName',
                data:dataObj
            }]
 
        });
 
    }
})

​​​​​​​



 
Hi,
Here is my script written in anonymous window to create record against opportuniyt for 3 month jan,feb,march but its not working please help me to solve




Map <Id, Opportunity> oppItems = new Map <Id, Opportunity>();
        
    list<ARRCalcualateOpportunity__c> Arropplist= new list<ARRCalcualateOpportunity__c>();
        list<Opportunity> opplist= new list<Opportunity>();
        
    for(opportunity opp:opplist){
       if (opp.StageName == 'Closed Won'&& opp.closeDate.month() >=1 && opp.closeDate.month() <=3 ) 
        {
          oppItems.put(opp.Id, opp);
        }
    }
    
    List<OpportunityLineItem> oliList = [select Id, Name, Product2Id, Product2.Family,opportunity.amount,opportunity.closedate from 
                                         OpportunityLineItem where OpportunityId IN:oppItems.keyset()];
        
        system.debug('oli'+ oliList);
        for(OpportunityLineItem oli :oliList)
        {
             for(Integer i =1;i<=12;i++)
                     {
                         if(oli.product2.family == 'software Recurring')
            {
              ARRCalcualateOpportunity__c arrOpp = new ARRCalcualateOpportunity__c();
             
                 arropp.name=string.valueOf(oli.opportunity.closedate);
                arropp.OpportunityArr__c= oli.OpportunityId;      
                arrOpp.Opportunity_Product__c= oli.product2Id;
                system.debug('arropp'+arropp);
              Arropplist.add(arropp);
            }
        }
        }
        
        if(Arropplist.size() >0){
          insert Arropplist;
            System.debug('arropp list'+arropplist);
        }
    
             


            
                 

                    
                    
HI All,

Here is another script tried to insert 3 related record for opprtunity for 3 month (Jan,feb,March). But not working can anyone help please.
Script
Map <Id, Opportunity> oppItems = new Map <Id, Opportunity>();
       
    list<ARRCalcualateOpportunity__c> Arropplist= new list<ARRCalcualateOpportunity__c>();
        list<Opportunity> opplist= new list<Opportunity>();
    for(opportunity opp:opplist){
       if (opp.StageName == 'Closed Won'&& opp.closeDate.month() >=1 && opp.closeDate.month() <=3 ) 
        {
          oppItems.put(opp.Id, opp);
        }
    }
    
    List<OpportunityLineItem> oliList = [select Id, Name, Product2Id, Product2.Family from 
                                         OpportunityLineItem where OpportunityId IN:oppItems.keyset()];
        
        for(OpportunityLineItem oli :oliList)
        {
             

            if(oli.product2.family == 'software Recurring__c')
                 
                //Date dt = oppobj.closedate;
                    
                     for(Integer i =1;i<=12;i++)
            {
              ARRCalcualateOpportunity__c arrOpp = new ARRCalcualateOpportunity__c();
              arropp.name = oppItems.get(oli.OpportunityId).Name;
              arropp.ownerId = oppItems.get(oli.OpportunityId).OwnerId; 
              arropp.OpportunityArr__c=oppItems.get(oli.OpportunityId).Id;  
                System.debug('arropp list'+arropp);
              Arropplist.add(arropp);
               System.debug('arropp list'+arropplist);
            }
        }
        
        if(Arropplist.size() >0){
          insert Arropplist;
        }
    

 
Hi all,
Here is my script to update opprtunity record on reled object for 3 month but its not creating record plz help me

script


 list<opportunity> opplist  =new list <opportunity>();  
 List <ARRCalcualateOpportunity__c> ArroppList = new List <ARRCalcualateOpportunity__c>();
    for (Opportunity oppobj : opplist) 
    {
       
        if (oppobj.StageName == 'Closed Won' && oppobj.closedate.month()>=1 && oppobj.closedate.month<=3)
        {  
            for(OpportunityLineItem Oli:[select Id,Name,Product2Id,Product2.Family from
                                         OpportunityLineItem where OpportunityId=:oppobj.Id])
            {
                
                 if(oli.Product2.Family =='Software Recurring')
                     
                 {
                     // To display date in asscending order
                   Date dt = oppobj.closedate;
                     for(Integer i =0;i<12;i++)
                    {
                        ARRCalcualateOpportunity__c arrObj = new ARRCalcualateOpportunity__c(); 
                      arrobj.ARRdate__c = oppobj.CloseDate;
                        //will display 12 date in ascending order
                     arrobj.ARRdate__c  =dt.addMonths(i);
                       arrobj.Name = oppobj.name;
                        arrobj.oppAmount__c = oppobj.Amount;
           List<OpportunityLineItem> oppli= [select Id from OpportunityLineItem 
                                              where OpportunityId = : oppobj.Id];
                       
                        arrobj.Opportunity_Product__c = oppli[0].id;
                       arrobj.OpportunityArr__c= oppobj.Id;                        
                        ArroppList.add(arrobj);
                        
                    }
                         
                   }   
            }
        }
    
    }
if(arropplist>0){

 insert ArroppList;
}