• Sangeetha T
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 18
    Replies
Hi All

While inserting test records through DATABASE.INSERT in test class. I queried the inserted TEST records through System.Debug, To my surprise I could see that the field value has got changed. 
Henceforth it is not passing to the another criteria to code coverage 

for eg I inserted 
F1 = "aqsh"
F2 = "assigned"

while querying the records look like this
F1 ="aqsh"
F2 = "Open"

PLEASE HELP
Exporting more 50K record information - Out of Box functionality
Hi 

I have 56K records name in hand, I need to export their repective Record ID and other fields. If I form the SOQL query like the following I will result in QUERY size limit exceeding 20K characters 
 
SELECT ID,Name from Object__c "WHERE Name IN ('dd',dd',..................) 

Optimizing the IN with batch by batch records is tidious 

Any better out of box functionality to extract 56K records field when you have their name

Thanks in advance 
SANGEETHA T
Hi All

Please help me in defining the CRON expression for running a scheduler class for every 30th min of an hour 
For example first run should be 9 30 next should be 10 30 next should be 11 30 

 
Hi All 

PFB Code snippet 

The goal of the batch job is basically finding the relationship (AOR) record from past year and apply the sales focus value to the new year AOR record if the sales focus value for past AOR is = 'Assigned" and the new year AOR record sales focus is "OPEN"

I'm getting 37% code coverage only, Please help where I have missed thanks 

 
global class BatchSalesfocusAORRollOver implements Database.Batchable<sObject> {

        public integer getCurrentFY(){ 
        
        Integer currentFY;      
        Organization orgInfo = [SELECT FiscalYearStartMonth, UsesStartDateAsFiscalYearName
                                FROM Organization WHERE id=:Userinfo.getOrganizationId()];
        Date today = system.today();
        if (today.month() >= orgInfo.FiscalYearStartMonth) {
            if (orgInfo.UsesStartDateAsFiscalYearName) 
                currentFY = today.year();             
            else currentFY = today.year() + 1; 
        }else {
            if (orgInfo.UsesStartDateAsFiscalYearName) 
                currentFY = today.year() - 1;
            else currentFY = today.year();            
        }
        System.debug('&&&&&&&&'+currentFY);                
        return currentFY;
    }      
             
    Integer FiscalYear = getCurrentFY();
    Integer FYPlusOne = FiscalYear - 1;
    // Variable defined to check if the previous fiscal year
    String PrevYearCheck = FYPlusOne +'%';

    global database.querylocator start(Database.BatchableContext BC){   
        Integer lmt = Limits.getLimitQueryRows();
        String National = System.Label.CL_National;
        String query = 'Select Org_SFID__r.Fiscal_Year_SFID__c,fAccount_Brand_ID__c,Id,CFY_Dealer_Account_SFID__r.Brand_Group_Name__c,Integration_Key__c,';     
        query += 'Org_SFID__c,Org_SFID__r.Fiscal_Year_SFID__r.Year__c,Sales_Focus_Descr__c';
        query += ' FROM Account_Org_Relationship__c';
        query += ' WHERE Sales_Focus_Descr__c =\'Assigned\' and is_Active__c = true and fFiscal_Year__c = false and Integration_Key__c LIKE PrevYearCheck and fAccount_Brand_Name__c =: National';
        
        System.debug('query ::::'+ query);
        return Database.getQueryLocator(query);        
    }
        
    global void execute(Database.BatchableContext BC, List<Account_Org_Relationship__c> AORCurrentFYList){
        String National = System.Label.CL_National;
        map<String,Account_Org_Relationship__c> FutureFYAORMap = new  map<String,Account_Org_Relationship__c>();
        System.debug('FiscalYear ::::'+ FiscalYear + 'FYPlusOne ::::'+ FYPlusOne );

        List<String> KeyList = new List<String>();
        for (Account_Org_Relationship__c scopeAOR: AORCurrentFYList) {
            Integer Key_length = String.valueOf(scopeAOR.Integration_Key__c).length();
            String Partial_Key = String.valueOf(scopeAOR.Integration_Key__c).substring(5, Key_length);
            String Complete_Key =  FYPlusOne + '|' + Partial_Key;
            KeyList.add(Complete_Key);
        }
        system.debug('KeyList    '+ KeyList);
  /*      List<Account_Org_Relationship__c> FutureFYAORList = [Select id,
                                                                    name,
                                                                    Sales_Focus_Descr__c,
                                                                    Integration_Key__c
                                                            From Account_Org_Relationship__c
                                                            Where Org_SFID__r.Fiscal_Year_SFID__r.name =: String.valueOf(FYPlusOne)];
 */
 
        for (Account_Org_Relationship__c AOR: [Select id,name,Sales_Focus_Descr__c,Integration_Key__c From Account_Org_Relationship__c
                                               Where is_Active__c = true and Sales_Focus_Descr__c = 'Open' AND fAccount_Brand_Name__c =: National and Org_SFID__r.Fiscal_Year_SFID__r.name =: String.valueOf(FYPlusOne) and Integration_Key__c in: KeyList])
        {
            If (AOR.Integration_Key__c !=null) {
                Integer Key_length = String.valueOf(AOR.Integration_Key__c).length();
                String Partial_Key = String.valueOf(AOR.Integration_Key__c).substring(5, Key_length);
                FutureFYAORMap.put(Partial_Key, AOR);
            }
        }
        system.debug('FutureFYAORMap :::::' + FutureFYAORMap);
        
        List<Account_Org_Relationship__c> AORUpdList = new List<Account_Org_Relationship__c>();
        Integer index = 0;
        for(Account_Org_Relationship__c AORold: AORCurrentFYList) {
            If (AORold.Integration_Key__c !=null) {
                Integer Key_length = String.valueOf(AORold.Integration_Key__c).length();
                String Partial_Key = String.valueOf(AORold.Integration_Key__c).substring(5, Key_length);
        
                if(FutureFYAORMap.containsKey(Partial_Key)) {
                    Account_Org_Relationship__c AORitem = new Account_Org_Relationship__c();
                    AORitem = FutureFYAORMap.get(Partial_Key);
                    AORitem.Sales_Focus_Descr__c = 'Assigned';
                    AORUpdList.add(AORitem);
                    index = index + 1;
                }
            }
        }
        system.debug('index @@@@@@' + index);
        database.update(AORUpdList);
    }

    global void finish(Database.BatchableContext BC) {

    }
}
 
@isTest
public class BatchSalesfocusAORRollOverTest{
 
    static testMethod void testApexFiveAOR()
     {
   
        //Creating Period Data Team record
      Integer FiscalYear;      
        Organization orgInfo = [SELECT FiscalYearStartMonth, UsesStartDateAsFiscalYearName
                                FROM Organization WHERE id=:Userinfo.getOrganizationId()
                               ];
        Date today = system.today();               
        if (today.month() >= orgInfo.FiscalYearStartMonth) {
            if (orgInfo.UsesStartDateAsFiscalYearName) {
                FiscalYear = today.year();
            }else{
                FiscalYear = today.year() + 1;
            }
        }else{
            if (orgInfo.UsesStartDateAsFiscalYearName) {
                FiscalYear = today.year() - 1;
            }else{
                FiscalYear = today.year();
            }
        }
  
      Integer FiscalYearplusone = FiscalYear - 1;
      
         
        Periods__c p = new Periods__c();
        p.CFY_Offset_ID__c = -1;
        p.Name=string.valueOf(FiscalYear-1);
        p.Year__c = FiscalYearplusone;   
        p.Period_Level_Descr__c ='Year'; 
        p.Period_ID__c ='20171';      
        insert p; 
      
        Periods__c p1 = new Periods__c();
        p1.CFY_Offset_ID__c = 0;
        p1.Name=string.valueOf(FiscalYear);
        p1.Year__c = FiscalYear;   
        p1.Period_Level_Descr__c ='Year'; 
        p1.Period_ID__c ='20181';    
        insert p1;    
        
        RecordType dealerRt = [SELECT Id FROM RecordType WHERE sObjectType='Account' and DeveloperName='Dealer'];
        RecordType growerRt = [SELECT Id FROM RecordType WHERE sObjectType='Account' and DeveloperName='Grower'];    
         
        List<Monsanto_Organizations__c> MORList = new List<Monsanto_Organizations__c>();
        //Creating Monsanto Organisation Data Team record
       
        Monsanto_Organizations__c MO3 = new Monsanto_Organizations__c();
        MO3.Name='IL Central' ;       
        MO3.Market_Type_Descr__c ='Seed and Traits';      
        MO3.Brand_Family_Name__c = 'National' ;       
        MO3.Org_Key_Cd__c ='2015|ABM|C101' ;       
        MO3.Org_Cd__c ='C101' ;       
        MO3.Org_Description__c ='IL Central';       
        MO3.Fiscal_Year_SFID__c = p.Id;
        MORList.add(MO3); 
        
        Monsanto_Organizations__c MO4 = new Monsanto_Organizations__c();
        MO4.Name='Lowell Butler' ;       
        MO4.Market_Type_Descr__c ='Seed and Traits';      
        MO4.Brand_Family_Name__c = 'National' ;       
        MO4.Org_Key_Cd__c ='2015|DSM|C1D' ;       
        MO4.Org_Cd__c ='C1D' ;       
        MO4.Org_Description__c ='Lowell Butler';       
        MO4.Fiscal_Year_SFID__c = p.Id;
        MO4.Manager_Org_SFID__c = MO3.id;
        MORList.add(MO4);  
         
        Monsanto_Organizations__c MO2 = new Monsanto_Organizations__c();
        MO2.Name='2015 - AG LAND FS INC ELV GREEN VLY' ;       
        MO2.Market_Type_Descr__c ='Seed and Traits';      
        MO2.Brand_Family_Name__c = 'National' ;       
        MO2.Org_Key_Cd__c ='2015|DealerNational50540711' ;       
        MO2.Org_Cd__c ='50540711' ;       
        MO2.Org_Description__c ='AG LAND FS INC ELV GREEN VLY';       
        MO2.Fiscal_Year_SFID__c = p1.Id;    
        MO2.Manager_Org_SFID__c = MO4.id;
        MORList.add(MO2);     
        
        database.insert(MORList, false); 
        
        //Creating Business Plan record
        Business_Plan__c bp = new Business_Plan__c();      
        bp.Name = '2015 Crop Plan' ;     
        bp.Integration_Key__c = 'Acc123asdhgasd' ;      
        bp.Market_Type_Descr__c ='All' ;      
        bp.BPY_SFID__c = p1.id;            
        insert bp ;  
        
        //Creating Sales Summary By Year record
        Sales_Summary_Level_By_Year__c ss0 = new Sales_Summary_Level_By_Year__c(is_Active__c = true,
        Category_Type_Descr__c = 'Brand',
        name='ss',
        Account_Type_Descr__c = 'Location',
        Product_Type_Descr__c = 'Bulk',
        Fiscal_Year_SFID__c =p1.id,
        Product_Summary_Level_Descr__c ='WEATHERMAX');      
        insert ss0;        

        //Creating District Sales Summary Record
        District_Sales_Summary_By_Year__c d = new District_Sales_Summary_By_Year__c( name = 'dst1',
        is_Active__c = true,
        Team_BP_SFID__c = bp.id, 
        Sales_Summary_Level_SFID__c = ss0.id,
        is_BP_Submitted__c = true,
   //     BP_Submitted_By_User_SFID__c = DSMMem.id ,
        BP_Submitted_Date__c = date.today() - 3 ,
        District_Org_SFID__c = MO2.id,
        BP_Approved_Date__c = date.today() - 4,
        BP_Rejected_Date__c = date.today() - 6);
        insert d;    
          
       // Create an Account    
       Account a2  = new Account();    
       a2.Name = 'TestDealer2';    
       a2.RecordTypeId = dealerRt.Id;
       a2.Brand_Group_Name__c = 'National';
       insert a2;

       // Create an Account    
       Account a0  = new Account();    
       a0.Name = 'TestDealer';    
       a0.RecordTypeId = dealerRt.Id;
       a0.Brand_Group_Name__c = 'National';
       insert a0; 
         
       Account a1  = new Account();    
       a1.Name = 'TestGrower';    
       a1.RecordTypeId = growerRt.Id;  
       a1.Brand_Group_Name__c = 'National';  
       insert a1;
   
       Account a3  = new Account();    
       a3.Name = 'TestGrower2';    
       a3.RecordTypeId = growerRt.Id;    
       a3.Brand_Group_Name__c = 'National';
       insert a3;
       
       
        //Creating Account Sales Summary By Year record
        Account_Sales_Summary_By_Year__c as0 = new Account_Sales_Summary_By_Year__c(Name = 'as',
        Account_SFID__c = a0.id, 
        District_Sales_Summary_SFID__c = d.Id,
        CFY_GNet_Sales_Qty__c = 26);
        insert as0;
        
        Account_Sales_Summary_By_Year__c as1 = new Account_Sales_Summary_By_Year__c(Name = 'as',
        Account_SFID__c = a2.id, 
        District_Sales_Summary_SFID__c = d.Id,
        CFY_GNet_Sales_Qty__c = 68);
        insert as1;    
     
        List<Account_Org_Relationship__c> AORListToInsert = new List<Account_Org_Relationship__c>();
        List<Account_Org_Relationship__c> AORListToUpdate = new List<Account_Org_Relationship__c>();
        
        Account_Org_Relationship__c aor0 = new Account_Org_Relationship__c(
        Name = 'TestAccOrgRelationship', 
        Account_SFID__c = a1.Id, 
        Org_Account_SFID__c = a0.Id,
        Org_SFID__c = MO2.Id, 
        Sales_Focus_Descr__c = 'Open', 
        CFY_Dealer_Account_SFID__c = a0.Id,
        Corn_Acct_Sls_Summ_SFID__c = as0.Id,
        Soy_Acct_Sls_Summ_SFID__c = as1.Id,
        CFY_Grower_Account_SFID__c = a1.Id,
        Integration_Key__c = String.ValueOf(FiscalYear) +'|test1',
        is_Active__c = true);  
        AORListToInsert.add(aor0);
        aor0.Sales_Focus_Descr__c = 'Assigned';
        AORListToUpdate.add(aor0); 

        
        Account_Org_Relationship__c aor1 = new Account_Org_Relationship__c(
        Name = 'TestAccOrgRelationship1', 
        Account_SFID__c = a1.Id, 
        Org_Account_SFID__c = a0.Id,
        Org_SFID__c = MO2.Id, 
        Sales_Focus_Descr__c = 'Open', 
        CFY_Dealer_Account_SFID__c = a0.Id,
        Corn_Acct_Sls_Summ_SFID__c = as0.Id,
        Soy_Acct_Sls_Summ_SFID__c = as1.Id,
        CFY_Grower_Account_SFID__c = a1.Id,
        Integration_Key__c = String.ValueOf(FiscalYear) +'|test2',
        is_Active__c = true);  
        AORListToInsert.add(aor1);
        aor1.Sales_Focus_Descr__c = 'Assigned';
        AORListToUpdate.add(aor1);         

        
        Account_Org_Relationship__c aor2 = new Account_Org_Relationship__c(
        Name = 'TestAccOrgRelationship2', 
        Account_SFID__c = a1.Id, 
        Org_Account_SFID__c = a0.Id,
        Org_SFID__c = MO2.Id, 
        Sales_Focus_Descr__c = 'Open', 
        CFY_Dealer_Account_SFID__c = a0.Id,
        Corn_Acct_Sls_Summ_SFID__c = as0.Id,
        Soy_Acct_Sls_Summ_SFID__c = as1.Id,
        CFY_Grower_Account_SFID__c = a1.Id,
        Integration_Key__c = String.ValueOf(FiscalYear) +'|test3',
        is_Active__c = true);  
        AORListToInsert.add(aor2);
        aor2.Sales_Focus_Descr__c = 'Assigned';
        AORListToUpdate.add(aor2);         

        
        Account_Org_Relationship__c aor3 = new Account_Org_Relationship__c(
        Name = 'TestAccOrgRelationship3', 
        Account_SFID__c = a1.Id, 
        Org_Account_SFID__c = a0.Id,
        Org_SFID__c = MO2.Id, 
        Sales_Focus_Descr__c = 'Open', 
        CFY_Dealer_Account_SFID__c = a0.Id,
        Corn_Acct_Sls_Summ_SFID__c = as0.Id,
        Soy_Acct_Sls_Summ_SFID__c = as1.Id,
        CFY_Grower_Account_SFID__c = a1.Id,
        Integration_Key__c = String.ValueOf(FiscalYear) +'|test4',
        is_Active__c = true);  
        AORListToInsert.add(aor3);
        aor3.Sales_Focus_Descr__c = 'Assigned';
        AORListToUpdate.add(aor3);         

        Account_Org_Relationship__c aor4 = new Account_Org_Relationship__c(
        Name = 'TestAccOrgRelationship', 
        Account_SFID__c = a1.Id, 
        Org_Account_SFID__c = a0.Id,
        Org_SFID__c = MO2.Id, 
        Sales_Focus_Descr__c = 'Open', 
        CFY_Dealer_Account_SFID__c = a0.Id,
        Corn_Acct_Sls_Summ_SFID__c = as0.Id,
        Soy_Acct_Sls_Summ_SFID__c = as1.Id,
        CFY_Grower_Account_SFID__c = a1.Id,
        Integration_Key__c = String.ValueOf(FiscalYear) +'|test5',
        is_Active__c = true);  
        AORListToInsert.add(aor4);
        aor4.Sales_Focus_Descr__c = 'Assigned';
        AORListToUpdate.add(aor4);         

              
       Account_Org_Relationship__c aor10 = new Account_Org_Relationship__c(
       Name = 'TestAccOrgRelationship', 
       Account_SFID__c = a1.Id, 
       Org_Account_SFID__c = a0.Id,
       Org_SFID__c = MO4.Id, 
       CFY_Dealer_Account_SFID__c = a0.Id,
       Corn_Acct_Sls_Summ_SFID__c = as0.Id,
       Soy_Acct_Sls_Summ_SFID__c = as1.Id,
       CFY_Grower_Account_SFID__c = a1.Id,
       Integration_Key__c = String.ValueOf(FiscalYearplusone) +'|test1',
       IsValid__c = false,
       Sales_Focus_Descr__c = 'Open',
       is_Active__c = true);  
       AORListToInsert.add(aor10);
       
       Account_Org_Relationship__c aor11 = new Account_Org_Relationship__c(
       Name = 'TestAccOrgRelationship', 
       Account_SFID__c = a1.Id, 
       Org_Account_SFID__c = a0.Id,
       Org_SFID__c = MO4.Id, 
       CFY_Dealer_Account_SFID__c = a0.Id,
       Corn_Acct_Sls_Summ_SFID__c = as0.Id,
       Soy_Acct_Sls_Summ_SFID__c = as1.Id,
       CFY_Grower_Account_SFID__c = a1.Id,
       Integration_Key__c = String.ValueOf(FiscalYearplusone) +'|test2',
       IsValid__c = false,
       Sales_Focus_Descr__c = 'Open',
       is_Active__c = true);  
       AORListToInsert.add(aor11);
       
       Account_Org_Relationship__c aor12 = new Account_Org_Relationship__c(
       Name = 'TestAccOrgRelationship', 
       Account_SFID__c = a1.Id, 
       Org_Account_SFID__c = a0.Id,
       Org_SFID__c = MO4.Id, 
       CFY_Dealer_Account_SFID__c = a0.Id,
       Corn_Acct_Sls_Summ_SFID__c = as0.Id,
       Soy_Acct_Sls_Summ_SFID__c = as1.Id,
       CFY_Grower_Account_SFID__c = a1.Id,
       Integration_Key__c = String.ValueOf(FiscalYearplusone) +'|test3',
       IsValid__c = false,
       Sales_Focus_Descr__c = 'Open',
       is_Active__c = true);  
       AORListToInsert.add(aor12);
       
       Account_Org_Relationship__c aor13 = new Account_Org_Relationship__c(
       Name = 'TestAccOrgRelationship', 
       Account_SFID__c = a1.Id, 
       Org_Account_SFID__c = a0.Id,
       Org_SFID__c = MO4.Id, 
       CFY_Dealer_Account_SFID__c = a0.Id,
       Corn_Acct_Sls_Summ_SFID__c = as0.Id,
       Soy_Acct_Sls_Summ_SFID__c = as1.Id,
       CFY_Grower_Account_SFID__c = a1.Id,
       Integration_Key__c = String.ValueOf(FiscalYearplusone) +'|test4',
       IsValid__c = false,
       Sales_Focus_Descr__c = 'Open',
       is_Active__c = true);  
       AORListToInsert.add(aor13);
       
       Account_Org_Relationship__c aor14 = new Account_Org_Relationship__c(
       Name = 'TestAccOrgRelationship', 
       Account_SFID__c = a1.Id, 
       Org_Account_SFID__c = a0.Id,
       Org_SFID__c = MO4.Id, 
       CFY_Dealer_Account_SFID__c = a0.Id,
       Corn_Acct_Sls_Summ_SFID__c = as0.Id,
       Soy_Acct_Sls_Summ_SFID__c = as1.Id,
       CFY_Grower_Account_SFID__c = a1.Id,
       Integration_Key__c = String.ValueOf(FiscalYearplusone) +'|test5',
       IsValid__c = false,
       Sales_Focus_Descr__c = 'Open',
       is_Active__c = true);  
       AORListToInsert.add(aor14);

        Test.startTest();
        if(AORListToInsert.size() >0 ){
            database.insert(AORListToInsert, false);
            database.update(AORListToUpdate, false);
        }   
        List<Account_Org_Relationship__c> aor = [Select fAccount_Brand_Name__c,Id,Integration_Key__c,fFiscal_Year__c,
                                           Org_SFID__c,Org_SFID__r.Fiscal_Year_SFID__r.Year__c,Sales_Focus_Descr__c FROM Account_Org_Relationship__c
                                           where Account_SFID__c = :a1.id];
        system.debug('aor ^^^^^^^^^^^^^'+aor);       
        BatchSalesfocusAORRollOver bc = new BatchSalesfocusAORRollOver();
        bc.getCurrentFY();
       database.executeBatch(bc);
        Test.stopTest();          
   
    }
}



 
Hi All 

I have a batch class as follows 
 
Integer FiscalYear = getCurrentFY();
    Integer FYPlusOne = FiscalYear - 1;

    global database.querylocator start(Database.BatchableContext BC){   
        Integer lmt = Limits.getLimitQueryRows();
        String query = 'Select Org_SFID__r.Fiscal_Year_SFID__c,fAccount_Brand_ID__c,Id,CFY_Dealer_Account_SFID__r.Brand_Group_Name__c,Integration_Key__c,';     
        query += 'Org_SFID__c,Org_SFID__r.Fiscal_Year_SFID__r.Year__c,Sales_Focus_Descr__c';
        query += ' FROM Account_Org_Relationship__c';
        query += ' WHERE Sales_Focus_Descr__c =\'Assigned\' and is_Active__c = True and fFiscal_Year__c = False and fAccount_Brand_Name__c =: National';

I need to add a condition to the query like Inte__key__c like 'FYPlusOne%' 

Intekey field value will be in the format of 2017|39238shdshdhkjsoskok. I have to fetch the records of the previous fiscal year so the inteley should contain 2017(Currentfiscalyear - 1) 

Please help me how to achieve this in where condition. I have a declared a variable on top 

Thanks 
Sangeetha T
User A  belongs to a public group, A report folder is created with Editor access to the pulbic group. User A can view the dashboard but face privilieges issue when trying access the report that is related to the dashboard component (by clicking on the component prompted to report)


Whats the issue here any idea 
Hi friends I have created a trigger in salesforce to find the number of contacts associated with an account 

The trigger is not firing for the existing records ...Is der any way to sort this if so ...How 

Thanks in advance 
Trigger ContactCountTrigger on Contact(After insert,After Delete,After Undelete)
{
  Set<Id> setAccountIds = new Set<Id>();
  
  //Whenever your working with After Undelete operation you can access data through 
  //Trigger.new or Trigger.newMap but not with Trigger.old or Trigger.oldmap variables
  if(Trigger.isInsert || Trigger.isUndelete)
  {
   for(Contact con : Trigger.new)
   {
    setAccountIds.add(con.AccountId);
   }
  }
  
  if(Trigger.isDelete)
  {
   //if you use Trigger.new below in place of Trigger.old you will end up with 
   //System.NullPointerException:Attempt to de-reference a null object
   for(Contact con : Trigger.old) 
   {
    setAccountIds.add(con.AccountId);
   }
  }
  
 List<Account> listAccs = [Select id,name,Number__c,(Select id from contacts) from Account where Id in : setAccountIds];
  for(Account acc :listAccs)
  {
   acc.Number__c= acc.contacts.size();
  }
  update listAccs;
}
}

 
Hi All

I have created a VF page to create a new contact and a button to show the list of  existing contacts

But when i click show the error "required fields"

How to have both command buttons on one single page 
When i click show it should show list of contacts 
<apex:page standardcontroller="Contact" extensions="contactslist">
<apex:form >
<apex:pageBlock title="Create a new contact">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Enter the details for creating a new contact" columns="2">
<apex:inputField value="{!contact.Lastname}" />
<apex:inputField value="{!contact.email}" required="true"/>
<apex:inputField value="{!contact.phone}" required="true"/>
<apex:inputField value="{!contact.AccountId}" required="true"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="List of contacts and Accounts">
<apex:pageBlockTable value="{!conli}" var="a">
<apex:column title="lastname" value="{!a.lastname}"/>
<apex:column title="email" value="{!a.email}"/>
<apex:column title="phone" value="{!a.phone}"/>
<apex:column title="Account_name" value="{!a.Account.name}"/>
<apex:column title="Account.Type" value="{!a.Account.Type}"/>
<apex:column title="Account.Industry" value="{!a.Account.Industry}"/>
</apex:pageBlockTable>
<Apex:commandButton value="show" action="{!show}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
 
public with sharing class contactslist
{

    public contactslist(ApexPages.StandardController controller) {

    }

public list<contact> conli {get; set;}
public pageReference show()
{
conli=[select lastname,Email, phone, Account.name, Account.Type, Account.Industry from contact where Account.name != Null order by Contact.CreatedDate];
return null;
}
}

 
Need test class for the following trigger with atleast 75 code coverage 

The below trigger  : Opportunity has a field where the associated  contact name should be populated (after lead conversion to acc,contact,opp)
trigger ContactNameUpdate on Lead (after update) 
{
  for(Lead l : System.Trigger.new) 
  {
    
   if(l.IsConverted && l.ConvertedOpportunityId != null) 
   { 
       
    Opportunity opp = [SELECT Id,Contact__c FROM Opportunity WHERE Id =: l.ConvertedOpportunityId];
    If(opp.Contact__c == null)
    { 
     opp.Contact__c = l.ConvertedContactId;
     update opp;
    }
   }
    
     
      
  }
Please give me the test class to cover 75 of code coverage to migration.......Very Critical
Please give me the test class to cover 75 of code coverage to migration.......Very Critical
Need test class for the following trigger with atleast 75 code coverage 
Trigger 1
The below trigger  : Lead and Contact have same checkbox fields, both object fields should have same value 
trigger checktheLeadCheckBox on Contact (after update) 
{
  for(Contact c : Trigger.New)
  {
    List<Lead> li = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Lead where Email =: c.Email AND IsConverted =: false]; 
    for(Lead l : li)
    {
     If(l.Id != null)
     { 
       l.Customer_of_PubKCyber__c=c.Customer_of_PubKCyber__c;
       l.Customer_of_PubKLaw__c = c.Customer_of_PubKLaw__c;
       update l;
     }
    }
  }
}
Trigger 2 
The below trigger : checking the value of the checkboxes on Contacts object based on a condition 
trigger updatecontactcheckbox on Opportunity (after insert, after update) 
{    
    for(Opportunity o : Trigger.New)
    {
  
     if( o.Contact__c != null)                 
     {      
       Contact c = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Contact where Id =: o.Contact__c ]; 
       
if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKCyber Newsletter'))
    {
         c.Customer_of_PubKCyber__c = True;
        
    }
    else if(o.Product_Name__c == 'PubKCyber Newsletter')
         { 
           c .Customer_of_PubKCyber__c = false;
           
         }
          
if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKLaw Newsletter'))
        { 
          c.Customer_of_PubKLaw__c= True;
         
        }
       else if(o.Product_Name__c == 'PubKLaw Newsletter')
         { 
           c.Customer_of_PubKLaw__c = false;            
         }
       update c; 
      }   
     }  
  }

Please give me the test class to cover 75 of code coverage to migration.......Very Critical
Please give me the test class to cover 75 of code coverage to migration.......Very Critical
Hi I'm stuck up in writing the test classes for the following triggers to achieve code coverage while deployment 

What would be the test class for the following trigger 

trigger 1

trigger checktheLeadCheckBox on Contact (after update) 
{
  for(Contact c : Trigger.New)
  {
    List<Lead> li = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Lead where Email =: c.Email AND IsConverted =: false]; 
    for(Lead l : li)
    {
     If(l.Id != null)
     {
      
      
       l.Customer_of_PubKCyber__c=c.Customer_of_PubKCyber__c;
       l.Customer_of_PubKLaw__c = c.Customer_of_PubKLaw__c;
       update l;
     }
    }
  }
}

Trigger 2

trigger updatecontactcheckbox on Opportunity (after insert, after update) 
{    
    for(Opportunity o : Trigger.New)
    {
  
     if( o.Contact__c != null)                 
     {      
       Contact c = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Contact where Id =: o.Contact__c ]; 
       
if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKCyber Newsletter'))
    {
         c.Customer_of_PubKCyber__c = True;
        
    }
    else if(o.Product_Name__c == 'PubKCyber Newsletter')
         { 
           c .Customer_of_PubKCyber__c = false;
           
         }
          
if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKLaw Newsletter'))
        { 
          c.Customer_of_PubKLaw__c= True;
         
        }
       else if(o.Product_Name__c == 'PubKLaw Newsletter')
         { 
           c.Customer_of_PubKLaw__c = false;            
         }
       update c; 
      }   
     }  
  }
Hi 
I want to map a field between lead and opportunity for converted lead. But I get the following error 
Error: Lead field length of 3,900 is greater than this field's length of 255
I cant change the data type of the of the opportunity field since it is associated with one workflow and formula field
then what are the other ways to resolve it ??

Please Note : I have migrated these changesets from sandbox to production(in dev it worked fine but production creates a problem)

Critical issue 

Hi I have two custom fields subscription_start_date and subscription_end_date on Opportunity object

Have a two custom checkbox customer1 and customer2 on Contact Object (These two checkboxes are checked from another workflow)

I have a requirement to that these checkboxes should be unchecked if today date does not lies between subscription_start_date and subscription_end_date

No i have to write a trigger with the condition

if (today date should be greater than or equal to subscription_start_date) and (lesser than or equal to subscription_end_date) and (customer1 checkbox should be checked)

{customer1=true }//should be checked

else 

{customer1=false}//should not be checked

 

 

The following is my trigger but does not gives expected result 

what is wrong 

 

trigger checkthecheckbox on Contact (before insert) {

Set<id> oppids = new set<id>();

for (Contact opp: Trigger.new)
{
 oppids.add(opp.id);
}

Map<id, opportunity> oppMap = new Map<id, opportunity>();
for(opportunity o : [select Subscription_Start_Date__c,Subscription_End_Date__c from opportunity where id in: oppids])
{
 
oppMap.put(o.id, o); 
}

for (Contact opp: Trigger.new)
{
if(oppMap.get(opp.Id).Subscription_Start_Date__c>=date.Today())
{
opp.Customer_of_PubKCyber__c=False;
}
 
}
}

 



I have two checkbox fields in Lead and Contact objects  These fields would be tick marked if the customer has purchased the product in the past and the subscription period is active. . 

The requirement is 
- For every record in the Lead and Contact object, need to check if there is an opportunity and opportunity product associated with it
- If true then check if the associated Product name in the Opportunity product object contains the text "PubKLaw" or "PubKCyber" and the current date falls between start date and end date found in the Opportunity Product object
- If true then the above checkbox fields on the Lead and Contact objects for that particular customer needs to be checked
- This check needs to be dynamic that when the subscription ends the tick mark on those fields should be automatically removed 

Can i go for trigger or workflow would do a trick
I have a custom field Contact__c on Opportunity object and that field should be populated with the value of ContactID of that opportunity
This should also work for the converted leads they turn into a contact and opportunity

How to achieve this using trigger ​​.It would be great if you give me the sample code
#Newtotrigger
Hi this is the requiremnt
i have to copy the standard field(Closedate) on opportunities object to custom filed(start_date__c) on Opportunities products object
and opportunities products have another field called enddate where enddate = start_date_c + 1 year + 14 days and also check according for leap year (i.e) leap year may have 1 day extra ​
Please help me with the apex trigger
Hi All

Please help me in defining the CRON expression for running a scheduler class for every 30th min of an hour 
For example first run should be 9 30 next should be 10 30 next should be 11 30 

 
Hi All 

I have a batch class as follows 
 
Integer FiscalYear = getCurrentFY();
    Integer FYPlusOne = FiscalYear - 1;

    global database.querylocator start(Database.BatchableContext BC){   
        Integer lmt = Limits.getLimitQueryRows();
        String query = 'Select Org_SFID__r.Fiscal_Year_SFID__c,fAccount_Brand_ID__c,Id,CFY_Dealer_Account_SFID__r.Brand_Group_Name__c,Integration_Key__c,';     
        query += 'Org_SFID__c,Org_SFID__r.Fiscal_Year_SFID__r.Year__c,Sales_Focus_Descr__c';
        query += ' FROM Account_Org_Relationship__c';
        query += ' WHERE Sales_Focus_Descr__c =\'Assigned\' and is_Active__c = True and fFiscal_Year__c = False and fAccount_Brand_Name__c =: National';

I need to add a condition to the query like Inte__key__c like 'FYPlusOne%' 

Intekey field value will be in the format of 2017|39238shdshdhkjsoskok. I have to fetch the records of the previous fiscal year so the inteley should contain 2017(Currentfiscalyear - 1) 

Please help me how to achieve this in where condition. I have a declared a variable on top 

Thanks 
Sangeetha T
Need test class for the following trigger with atleast 75 code coverage 

The below trigger  : Opportunity has a field where the associated  contact name should be populated (after lead conversion to acc,contact,opp)
trigger ContactNameUpdate on Lead (after update) 
{
  for(Lead l : System.Trigger.new) 
  {
    
   if(l.IsConverted && l.ConvertedOpportunityId != null) 
   { 
       
    Opportunity opp = [SELECT Id,Contact__c FROM Opportunity WHERE Id =: l.ConvertedOpportunityId];
    If(opp.Contact__c == null)
    { 
     opp.Contact__c = l.ConvertedContactId;
     update opp;
    }
   }
    
     
      
  }
Please give me the test class to cover 75 of code coverage to migration.......Very Critical
Please give me the test class to cover 75 of code coverage to migration.......Very Critical
HELP!
I am getting the below error when I try to check my challenge:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Update failed. First exception on row 0 with id 0016100000PUJDEAA5; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 301610000005A3l. Contact your administrator for help.: []

How do I fix this?
Hi I'm stuck up in writing the test classes for the following triggers to achieve code coverage while deployment 

What would be the test class for the following trigger 

trigger 1

trigger checktheLeadCheckBox on Contact (after update) 
{
  for(Contact c : Trigger.New)
  {
    List<Lead> li = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Lead where Email =: c.Email AND IsConverted =: false]; 
    for(Lead l : li)
    {
     If(l.Id != null)
     {
      
      
       l.Customer_of_PubKCyber__c=c.Customer_of_PubKCyber__c;
       l.Customer_of_PubKLaw__c = c.Customer_of_PubKLaw__c;
       update l;
     }
    }
  }
}

Trigger 2

trigger updatecontactcheckbox on Opportunity (after insert, after update) 
{    
    for(Opportunity o : Trigger.New)
    {
  
     if( o.Contact__c != null)                 
     {      
       Contact c = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Contact where Id =: o.Contact__c ]; 
       
if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKCyber Newsletter'))
    {
         c.Customer_of_PubKCyber__c = True;
        
    }
    else if(o.Product_Name__c == 'PubKCyber Newsletter')
         { 
           c .Customer_of_PubKCyber__c = false;
           
         }
          
if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKLaw Newsletter'))
        { 
          c.Customer_of_PubKLaw__c= True;
         
        }
       else if(o.Product_Name__c == 'PubKLaw Newsletter')
         { 
           c.Customer_of_PubKLaw__c = false;            
         }
       update c; 
      }   
     }  
  }
Hi 
I want to map a field between lead and opportunity for converted lead. But I get the following error 
Error: Lead field length of 3,900 is greater than this field's length of 255
I cant change the data type of the of the opportunity field since it is associated with one workflow and formula field
then what are the other ways to resolve it ??

Please Note : I have migrated these changesets from sandbox to production(in dev it worked fine but production creates a problem)

Critical issue 

Hi I have two custom fields subscription_start_date and subscription_end_date on Opportunity object

Have a two custom checkbox customer1 and customer2 on Contact Object (These two checkboxes are checked from another workflow)

I have a requirement to that these checkboxes should be unchecked if today date does not lies between subscription_start_date and subscription_end_date

No i have to write a trigger with the condition

if (today date should be greater than or equal to subscription_start_date) and (lesser than or equal to subscription_end_date) and (customer1 checkbox should be checked)

{customer1=true }//should be checked

else 

{customer1=false}//should not be checked

 

 

The following is my trigger but does not gives expected result 

what is wrong 

 

trigger checkthecheckbox on Contact (before insert) {

Set<id> oppids = new set<id>();

for (Contact opp: Trigger.new)
{
 oppids.add(opp.id);
}

Map<id, opportunity> oppMap = new Map<id, opportunity>();
for(opportunity o : [select Subscription_Start_Date__c,Subscription_End_Date__c from opportunity where id in: oppids])
{
 
oppMap.put(o.id, o); 
}

for (Contact opp: Trigger.new)
{
if(oppMap.get(opp.Id).Subscription_Start_Date__c>=date.Today())
{
opp.Customer_of_PubKCyber__c=False;
}
 
}
}

 

I have a custom field Contact__c on Opportunity object and that field should be populated with the value of ContactID of that opportunity
This should also work for the converted leads they turn into a contact and opportunity

How to achieve this using trigger ​​.It would be great if you give me the sample code
#Newtotrigger
Hi this is the requiremnt
i have to copy the standard field(Closedate) on opportunities object to custom filed(start_date__c) on Opportunities products object
and opportunities products have another field called enddate where enddate = start_date_c + 1 year + 14 days and also check according for leap year (i.e) leap year may have 1 day extra ​
Please help me with the apex trigger
I am using a Mydomain enabled dev org on gs0 (Winter 16) and going throught the exercise in Trailhead. 

Follwed every step and when i click on Preview it takes me to my app (looks right) - https://skypeforbiz-dev-ed.lightning.force.com/c/Sfb.app

But it errors out with -

Lightning components require My Domain. Please contact your system administrator for more information.

Any idea what I might be missing? My org is defenitely provisioned with MyDomin.