• murdoc
  • NEWBIE
  • 10 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 12
    Replies
I am attempting to create a valid test for a method that is looking at abbreviations. This is the method:
public static string returnAbbreviationsIgnoredstring(string matchString){
        
        list<string> lstMatchedStrings = matchString.split(' ');
        set<string> setAccountAbbreviations = retrieveAccountAbbreviations();
        string cleanString = '';
        system.debug('##--returnAbbreviationsIgnoredstring.lstMatchedStrings: '+ lstMatchedStrings);
        for(string objString : lstMatchedStrings){
            system.debug('##--objString matches: '+ setAccountAbbreviations.contains(objString));
            if(setAccountAbbreviations.contains(objString.trim().toLowerCase())){
                continue;
            }
            cleanString += objString+ ' ';
        }// end of for-each
        
        system.debug('##--returnAbbreviationsIgnoredstring.cleanString: '+ cleanString);
        return cleanString.trim();
        
    }// end of returnAbbreviationsIgnoredstring
Any help would be greatly appreciated. Thanks.
 
  • September 10, 2019
  • Like
  • 0
Hola homies,

I inherited a class that is mired in nonsense and I need help writing a test class for a particular method. If I get it right I can replicate the test class and significantly raise the coverage on this class. HELP! Please.Here is the method. Thanks in advance!
public static List<Task> returnUpdateTaskListOwner(List<Opportunity> updateOpprtunityOwner,Map<Id, List<Task>> oppTaskMap,Map<Id,Opportunity> oldOppMap){
        List<Task> tempListUpdate=new List<Task>();
        if(updateOpprtunityOwner != null && updateOpprtunityOwner.size() > 0){
                    for(Opportunity opp : updateOpprtunityOwner){
                        if(oppTaskMap.containsKey(opp.Id)) {
                            List<Task> tempList=oppTaskMap.get(opp.Id);
                                for(Task t : tempList){//I-155449 Changes to check task subject
                                        System.debug('>>>task>>'+t.Subject);
                                    if(t.OwnerId == oldOppMap.get(opp.Id).OwnerId && t.Status != 'Completed' && taskWithOwner.contains(t.Subject)){
                                        System.debug('>>>>>updatetaskwithid'+t.id);
                                        t.OwnerId=opp.OwnerId;
                                        tempListUpdate.add(t);
                                    }
                                }
                        }
                    }
                }
            return tempListUpdate;
    }

 
So, I have a situation where I am trying to update a custom field that is a lookup to the User record. There is a csv sheet that is being uploaded to write to this field. It gives me the first and last name and that's it. I think this needs to be done in a trigger but I am unsure where to start. The look up field is called Prospect_Owner__c which sits on an object called Exhibitors. Any help would be greatly appreciate and would come with copious amounts of thank yous and good vibes!
  • November 13, 2018
  • Like
  • 0
Hey all!
I have an old formula in our org and I'm trying to make sure it's doing what I think it's doing? If not we got some 'splaining to do. :) Anyway here's the code:
IF(AND(NOT(ISPICKVAL(Type , "General, Corporate Event, Exposition, Non-Revenue, Sub-Contract, Maritz" )),(RecordTypeId = "0123000000092IT")

&&
TODAY() >= DATE( IF(MONTH(Pipeline_Date__c)=12, YEAR(Pipeline_Date__c )+1, YEAR(Pipeline_Date__c )), IF(MONTH(Pipeline_Date__c)=12,1,MONTH(Pipeline_Date__c)+1), 15)),
Total_Revenue_Actual__c ,
Amount )

Okay, what do you think it's doing? I will speak about you very fondly if you can figure it out. Thanks!
I am trying to increase my code coverage from 59% to the required 75 for deployment. Below is my class.
 
public class ForecastedRevCon {
    public Integer size{get;set;}
    public Id oppId {get;set;}
    public Opportunity oppRec {get;set;}
    public String oppName {get; set;}
    
    public Decimal totExSelling {get;set;}
    public Decimal totNonExSelling {get;set;}
    public Decimal totSellingCredit {get;set;}
    public Decimal totExRevenue {get;set;}
    public Decimal totNonExRevenue {get;set;}
    public Decimal totOppRevenue {get;set;}
    
    public Decimal forRevTot {get;set;}
    
    public List<ForecastedRevConWrapper> listSellingCreditDet {get; set;}
    public List<ForecastedRevConWrapper> listRevenueCenter {get; set;}
    
    public List<ForecastedRevConWrapper> listSellingCreditDetDelete {get; set;}
    public List<ForecastedRevConWrapper> listRevenueCenterDelete {get; set;}
    
    public Map<String, Decimal> mapForcatedRevDet {get;set;}

    public ForecastedRevCon(ApexPages.StandardController stdCon) {
        
        oppId = Apexpages.currentPage().getParameters().get('oppId');
        init();
    }
    
    public void init(){
        Integer i = 0;
        
        forRevTot = 0;
        initRevDetMap();
        
        totExSelling = 0;
        totNonExSelling = 0;
        totSellingCredit = 0;
        totExRevenue = 0;
        totNonExRevenue = 0;
        totOppRevenue = 0;
        
        listSellingCreditDet = new List<ForecastedRevConWrapper>();
        listSellingCreditDetDelete = new List<ForecastedRevConWrapper>();
        
        listRevenueCenter = new List<ForecastedRevConWrapper>();
        listRevenueCenterDelete = new List<ForecastedRevConWrapper>();
        
        if(oppId !=null) {
            
            for(Opportunity op: [SELECT Id, Name,Event_Number__c  FROM Opportunity WHERE Id =: oppId]){
                oppRec = op;
                oppName = op.Name;
            }
            
            for(FreemanXP_Forecasted_Revenue_Detail__c FRD: [SELECT Id, 
                                                                   Sold_By__c,
                                                                   Amount__c, 
                                                                   Exclusive_Non__c,
                                                                   Non_Exclusive__c,
                                                                   Exclusive__c,
                                                                   Forecasted_Revenue_Type__c
                                                                   FROM FreemanXP_Forecasted_Revenue_Detail__c 
                                                                   WHERE Opportunity__c =: oppId order by createdDate]) {
                                                                        
                                                                        listSellingCreditDet.add(new ForecastedRevConWrapper(FRD, i));
                                                                        i++;
           }
           
           i = 0;
           for(FreemanXP_Revenue_Center_Details__c FRC: [SELECT Id,
                                                                Revenue_Center__c,
                                                                Opportunity__c,
                                                                Job_Number__c,
                                                                Exclusive__c,
                                                                Non_Exclusive__c,
                                                                Expo_Producing_Branch__c
                                                                FROM FreemanXP_Revenue_Center_Details__c
                                                                WHERE Opportunity__c =: oppId order by createdDate]){
                                                                    
                                                                    listRevenueCenter.add(new ForecastedRevConWrapper(FRC, i));
                                                                    i++;
           }
           calcTotal();
        }
        else{
            //handle if opportunity Id not supplied in param 
        }
    }
    
    public void initRevDetMap(){
        
        mapForcatedRevDet = new Map<String, Decimal>();
        
        /*mapForcatedRevDet.put('AlfordRevenue',0);
        mapForcatedRevDet.put('Cleaning',0);
        mapForcatedRevDet.put('ShowManagement',0);
        mapForcatedRevDet.put('Decorating',0);
        mapForcatedRevDet.put('Freight',0);
        mapForcatedRevDet.put('ExhibitTransportation',0);
        mapForcatedRevDet.put('Utilities',0);
        mapForcatedRevDet.put('Electrical',0);
        mapForcatedRevDet.put('OverheadRigging',0);
        mapForcatedRevDet.put('Technology',0);
        mapForcatedRevDet.put('Other',0);
        mapForcatedRevDet.put('Customs',0);
        mapForcatedRevDet.put('Alford',0);
        mapForcatedRevDet.put('AudioVisual',0);
        mapForcatedRevDet.put('DigitalServices',0);
        mapForcatedRevDet.put('Encore',0);
        mapForcatedRevDet.put('Entertainment',0);
        mapForcatedRevDet.put('ExperienceDesign',0);
        mapForecatedRevDet.put('ExhibitSurveys',0);
        mapForcatedRevDet.put('ProductionManagement',0);
        mapForcatedRevDet.put('Sponsorship',0);
        mapForcatedRevDet.put('SpecialEvents',0);
        mapForcatedRevDet.put('StrategyandUK',0);*/
        
        mapForcatedRevDet.put('Alford',0);
        mapForcatedRevDet.put('AudioVisual',0);
        mapForcatedRevDet.put('Cleaning',0);
        mapForcatedRevDet.put('CustomConstructionRevenue',0);
        mapForcatedRevDet.put('Decorating',0);
        mapForcatedRevDet.put('Electrical',0);
        mapForcatedRevDet.put('Encore',0);
        mapForcatedRevDet.put('ExhibitTransportation',0);
        mapForcatedRevDet.put('Freight',0);
        mapForcatedRevDet.put('FXPDigitalServices',0);
        mapForcatedRevDet.put('FXPEntertainment',0);
        mapForcatedRevDet.put('FXPExhibitSurveys',0);
        mapForcatedRevDet.put('FXPExperienceDesign',0);
        mapForcatedRevDet.put('FXPProductionManagementFee',0);
        mapForcatedRevDet.put('FXPSpecialEvents',0);
        mapForcatedRevDet.put('FXPStrategy',0);
        mapForcatedRevDet.put('Other',0);
        mapForcatedRevDet.put('OverheadRigging',0);
        mapForcatedRevDet.put('SeattleManagementFees',0);
        mapForcatedRevDet.put('ShowManagement',0);
        mapForcatedRevDet.put('FXPSponsorshipRevenue',0);
        mapForcatedRevDet.put('Technology',0);
        mapForcatedRevDet.put('UK',0);
        mapForcatedRevDet.put('Utilities',0);
    }

    public PageReference addRowSellingCredit() {
        Integer newindex = 0;
        
        String recType = Apexpages.currentPage().getParameters().get('recType');
        
        Apexpages.currentPage().getParameters().put('oppId', oppId );
        
        if(recType.equals('selling')){
            for(ForecastedRevConWrapper fx : listSellingCreditDet){
            newindex = fx.index;
            }
            newindex++;
        
            if(listSellingCreditDet != null){
                listSellingCreditDet.add(new ForecastedRevConWrapper(new FreemanXP_Forecasted_Revenue_Detail__c(Opportunity__c =oppId), newindex));
            }
        }
        else {
            for(ForecastedRevConWrapper fx : listRevenueCenter){
                newindex = fx.index;
            }
            newindex++;
            
            if(listRevenueCenter != null){
                listRevenueCenter.add(new ForecastedRevConWrapper(new FreemanXP_Revenue_Center_Details__c(Opportunity__c =oppId), newindex));
            }
        }
        return null;
    }
    
    public Pagereference deleteRowSellingCredit() {
        Integer index = Integer.valueOf(Apexpages.currentPage().getParameters().get('index'));
        String recType = Apexpages.currentPage().getParameters().get('recType');
        Integer delIndex = 0;
        
        if(recType.equals('selling')) {
            
            if(listSellingCreditDet.size() == 0){
                return null;
            }
                    
            for(Integer i=0;i<listSellingCreditDet.size(); i++){
                
                ForecastedRevConWrapper fx = listSellingCreditDet.get(i);
                if(fx.index == index){
                    fx.isDelete = true;
                    delIndex = i;
                    listSellingCreditDetDelete.add(fx);  
                }
            }
            listSellingCreditDet.remove(delIndex);
        }
        else {
            
            if(listRevenueCenter.size() == 0){
                return null;
            }
                    
            for(Integer i=0;i<listRevenueCenter.size(); i++){
                
                ForecastedRevConWrapper fx = listRevenueCenter.get(i);
                if(fx.index == index){
                    fx.isDelete = true;
                    delIndex = i;
                    listRevenueCenterDelete.add(fx); 
                }
            }
            listRevenueCenter.remove(delIndex);
        }
        
        calcTotal();
        
        return null;
    }
    
    public PageReference saveForecastedRev(){
        
        /*if(totSellingCredit != totOppRevenue){
            Apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Error, Label.Selling_Credit_Save_Validation);
            Apexpages.addmessage(msg);
            return null;
        }*/
        
        List<FreemanXP_Forecasted_Revenue_Detail__c> listRecordUpsert = new List<FreemanXP_Forecasted_Revenue_Detail__c>();
        List<FreemanXP_Forecasted_Revenue_Detail__c> listRecordDelete = new List<FreemanXP_Forecasted_Revenue_Detail__c>();
        
        List<FreemanXP_Revenue_Center_Details__c> listRevenueUpsert = new List<FreemanXP_Revenue_Center_Details__c>();
        List<FreemanXP_Revenue_Center_Details__c> listRevenueDelete = new List<FreemanXP_Revenue_Center_Details__c>();
        
        for(ForecastedRevConWrapper fx : listSellingCreditDet){
            
            if(/*fx.wrapRecord.amount__c !=null && */!fx.isDelete) {
                listRecordUpsert.add(fx.wrapRecord);
            }
        }
        
        for(ForecastedRevConWrapper fx : listSellingCreditDetDelete){
            
            if(fx.isDelete && fx.wrapRecord.Id != null) {
                listRecordDelete.add(fx.wrapRecord);
            }
        }
        
        for(ForecastedRevConWrapper fx : listRevenueCenter){
            
            if(fx.revCenter.Revenue_Center__c !=null && !fx.isDelete) {
                listRevenueUpsert.add(fx.revCenter);
            }
        }
        
        for(ForecastedRevConWrapper fx : listRevenueCenterDelete){
            
            if(fx.isDelete && fx.revCenter.Id != null) {
                listRevenueDelete.add(fx.revCenter);
            }
        }
        
        try{
            if(!listRecordUpsert.isEmpty()){
                upsert listRecordUpsert;
            }
            if(!listRecordDelete.isEmpty()){
                delete listRecordDelete;
            }
            if(!listRevenueUpsert.isEmpty()){
                  
                    //if(listRevenueUpsert.get(0).Job_Number__c != null && listRevenueUpsert.get(0).Job_Number__c.length() <= 6){
                        //oppRec.Event_Number__c = listRevenueUpsert.get(0).Job_Number__c;
                    //}
                  for(FreemanXP_Revenue_Center_Details__c rcd: listRevenueUpsert){
                    if(rcd.Expo_Producing_Branch__c){
                      oppRec.Event_Number__c = rcd.Job_Number__c;
                    }
                  }
              upsert listRevenueUpsert;
            }
            if(!listRevenueDelete.isEmpty()){
                delete listRevenueDelete;
            }
            
            update oppRec;
            
            init();
            
            Apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Record(s) Saved Successfully!');
            Apexpages.addmessage(msg);
            return new PageReference('/'+oppRec.Id);
        }
        catch(Exception ex){
            Apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Error,ex.getMessage());
            Apexpages.addmessage(msg);
        }
        
        return null;
    }
    
    public PageReference calcTotal(){
        
        initRevDetMap();
        forRevTot = 0;
        totExSelling = 0;
        totNonExSelling = 0;
        totSellingCredit = 0;
        totExRevenue = 0;
        totNonExRevenue = 0;
        totOppRevenue = 0;
        
        for(ForecastedRevConWrapper fx : listSellingCreditDet){
            try {
                totNonExSelling += (fx.wrapRecord.Non_Exclusive__c !=null ? fx.wrapRecord.Non_Exclusive__c: 0);
                totExSelling += (fx.wrapRecord.Exclusive__c !=null ? fx.wrapRecord.Exclusive__c: 0);
                
                decimal val = (fx.wrapRecord.Non_Exclusive__c !=null ? fx.wrapRecord.Non_Exclusive__c: 0) + (fx.wrapRecord.Exclusive__c !=null ? fx.wrapRecord.Exclusive__c: 0);
                totSellingCredit += val;
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Cleaning')){
                    updateValue('Cleaning', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Decorating')){
                    updateValue('Decorating', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Audio Visual')){
                    updateValue('AudioVisual', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Experience Design')){
                    updateValue('FXPExperienceDesign', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Show Management')){
                    updateValue('ShowManagement', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Freight')){
                    updateValue('Freight', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Exhibit Transportation')){
                    updateValue('ExhibitTransportation', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Utilities')){
                    updateValue('Utilities', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Electrical')){
                    updateValue('Electrical', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Overhead Rigging')){
                    updateValue('OverheadRigging', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Technology')){
                    updateValue('Technology', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Other')){
                    updateValue('Other', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Custom Construction Revenue')){
                    updateValue('CustomConstructionRevenue', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Alford')){
                    updateValue('Alford', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Digital Services')){
                    updateValue('FXPDigitalServices', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Encore')){
                    updateValue('Encore', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Entertainment')){
                    updateValue('FXPEntertainment', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Exhibit Surveys')){
                    updateValue('FXPExhibitSurveys', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Production Management Fee')){
                    updateValue('FXPProductionManagementFee', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Sponsorship Revenue')){
                    updateValue('FXPSponsorshipRevenue', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Special Events')){
                    updateValue('FXPSpecialEvents', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Strategy')){
                    updateValue('FXPStrategy', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('UK')){
                    updateValue('UK', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Seattle Management Fees')){
                    updateValue('SeattleManagementFees', val); 
                }
            }
            catch(Exception ex){}
        }
        
         for(ForecastedRevConWrapper fx : listRevenueCenter){
            
            try {
                
                totNonExRevenue += (fx.revCenter.Non_Exclusive__c !=null ? fx.revCenter.Non_Exclusive__c: 0);
                totExRevenue += (fx.revCenter.Exclusive__c !=null ? fx.revCenter.Exclusive__c: 0);
                
                decimal val = (fx.revCenter.Non_Exclusive__c !=null ? fx.revCenter.Non_Exclusive__c: 0) + (fx.revCenter.Exclusive__c !=null ? fx.revCenter.Exclusive__c: 0);
                totOppRevenue += val;
                                
             }
            catch(Exception ex){}
        }
        
        for(Decimal val: mapForcatedRevDet.values()){
            forRevTot += val;
        }
        
        return null;
    }

    public void updateValue(String key, Decimal v){
        Decimal ov = mapForcatedRevDet.get(key);
         ov += v;
         mapForcatedRevDet.put(key, ov);
    }
    
    public PageReference updateMainJob(){
      Integer index = Integer.valueOf(Apexpages.currentPage().getParameters().get('index'));
      
      
      List<FreemanXP_Revenue_Center_Details__c> listRev = new List<FreemanXP_Revenue_Center_Details__c>();
      
      if(listRevenueCenter.size() == 0){
        return null;
      }
              
      for(Integer i=0;i<listRevenueCenter.size(); i++){
 
          ForecastedRevConWrapper fx = listRevenueCenter.get(i);
          FreemanXP_Revenue_Center_Details__c rc = fx.revCenter;
          if(fx.index == index){
            rc.Expo_Producing_Branch__c = true;
            oppRec.Event_Number__c = rc.Job_Number__c;
          }
          else{
            rc.Expo_Producing_Branch__c = false;
          }
          listRev.add(rc);
      }
      
      try{
        if(!listRev.isEmpty()){
          upsert listRev;
          //oppRec.Event_Number__c = rc.Job_Number__c;
          update oppRec;
          init();
        }
      }
      catch(Exception ex){
         Apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Error,ex.getMessage());
         Apexpages.addmessage(msg);
      }
      return null;
    }
        public class ForecastedRevConWrapper {
            public FreemanXP_Forecasted_Revenue_Detail__c wrapRecord {get;set;}
            public FreemanXP_Revenue_Center_Details__c revCenter {get;set;}
            public integer index {get;set;}
            public Boolean isDelete {get;set;}
            
            public ForecastedRevConWrapper(FreemanXP_Forecasted_Revenue_Detail__c obj, Integer index){
              this.wrapRecord = obj;
              this.index = index;
              this.isDelete = false;
            }
            
            public ForecastedRevConWrapper(FreemanXP_Revenue_Center_Details__c obj, Integer index){
              this.revCenter = obj;
              this.index = index;
              this.isDelete = false;
            }
     
       }
}
And here is my test Class:
@isTest
private class ForecastedRevConTest {
    
    private static Opportunity opp;
    
    static testMethod void myUnitTest() {
        
        createTestData();
        
        Test.startTest();
           ApexPages.currentPage().getParameters().put('id',opp.Id);
           
           ApexPages.StandardController std = new ApexPages.Standardcontroller(opp);
           
           ForecastedRevCon controller = new ForecastedRevCon(std);
           
           ApexPages.currentPage().getParameters().put('recType','selling');
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           ApexPages.currentPage().getParameters().put('recType','rev');
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           
           ApexPages.currentPage().getParameters().put('index',1+'');
           ApexPages.currentPage().getParameters().put('recType','selling');
           
           controller.deleteRowSellingCredit();
           ApexPages.currentPage().getParameters().put('index',1+'');
           ApexPages.currentPage().getParameters().put('recType','rev');
           
           controller.deleteRowSellingCredit();
           
           controller.saveForecastedRev();
           
           
        Test.stopTest();
    }
    
    static testMethod void myUnitTestB() {
        
        createTestData();
        
        Test.startTest();
           ApexPages.currentPage().getParameters().put('id',opp.Id);
           
           ApexPages.StandardController std = new ApexPages.Standardcontroller(opp);
           
           ForecastedRevCon controller = new ForecastedRevCon(std);
           
           ApexPages.currentPage().getParameters().put('recType','selling');
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           ApexPages.currentPage().getParameters().put('recType','rev');
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           
           ApexPages.currentPage().getParameters().put('index',2+'');
           ApexPages.currentPage().getParameters().put('recType','selling');
           
           controller.deleteRowSellingCredit();
           ApexPages.currentPage().getParameters().put('index',2+'');
           ApexPages.currentPage().getParameters().put('recType','rev');
           
           controller.deleteRowSellingCredit();
           
           controller.saveForecastedRev();
           
           
        Test.stopTest();
    }
        
    public static void createTestData(){
        Id rtId;
        Map<String, Schema.SObjectType> sObjectMap = Schema.getGlobalDescribe() ;
        Schema.SObjectType s = sObjectMap.get('Opportunity') ; // getting Sobject Type
        Schema.DescribeSObjectResult resSchema = s.getDescribe() ;
        Map<String,Schema.RecordTypeInfo> recordTypeInfo = resSchema.getRecordTypeInfosByName(); //getting all Recordtype for the Sobject
        rtId = recordTypeInfo.get('Exposition Services').getRecordTypeId();//particular RecordId by  Name
        
        Account a = new Account(Name = 'Test Account', 
                        Type = 'test type', 
                        fax='123456789x23', 
                        BillingStreet = 'test Street', 
                        BillingCity = 'test City', 
                        BillingCountry = 'test Country', 
                        BillingState = 'GA', 
                        BillingPostalCode = '23456', 
                        Phone = '123456789x24', 
                        Customer_Number__c = '123456' );                            
        insert a;                                         
            
        opp = new Opportunity(Name = 'Test Opp',
                                        RecordTypeId = rtId,
                                        AccountId = a.Id,
                                        Type = 'test type',
                                        New_Existing__c = 'New',
                                        CloseDate = date.today(),
                                        StageName = 'Proposed',
                                        Show_Management_Revenue_Est__c = 15100,
                                        Producing_Branch__c = 'FDC',/* ANAHEIM (128)',*/
                                        /*Show_Opening_Date__c = Date.today().addDays(5),*/
                                        Probability = 25,
                                        Event_Number__c = '234567'
                                        );
        insert opp;
        
    }
}
Any help would be greatly appreciated! As always it's urgent. :) Thanks!

 
  • December 17, 2016
  • Like
  • 0
I'm sure this is pretty standard, but we have a major problem as we're in the middle of a deployment. I got this error when trying to deploy this test class: System.QueryException: Non-Selective Query against large object type. Consider an indexed filter. I need to adjust this so I can get this deployed. Any ideas as to how to index this line so I can get it to pass. Any help would be greatly appreciated. Thanks! Below is the portion of code in question.

 Opportunity campOpp = [Select Campaign.Parent.Id, Show_Campaign_ID__c from opportunity where id = :o4.id];
        System.debug('campOpp ->' + campOpp);
      
        System.currentPageReference().getParameters().put('opportunityId', o4.Id);
        List<Opportunity> listOpps = new List<Opportunity>([Select o.AccountId, o.Show_Campaign_ID__c,
        o.Campaign.Show_Close_Date__c, Name, Account_Manager__r.Name, (Select Id,  
        IsDeleted, Name, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp,
        LastActivityDate, ConnectionReceivedId, ConnectionSentId, Opp_Show_Name__c,
        Opp_Owner__c, Opp_Acct_Management_Producing__c, Opp_Acct_Management_Local_AE__c,
        Opp_Job_Number__c, Opp_Facility_City__c, Opp_Facility__c, Opp_Exhibit_Hall__c,
        Opp_Square_Footage__c, Opp_Exhibitor_Count__c, Opp_Producing_Branch__c, Opp_Show_Move_In__c,
        Opp_Show_Move_Out__c, Opp_Show_Opening_Date__c, Opp_Show_Close_Date__c,
        Do_we_have_overhead_rigging__c, Do_we_have_electrical_revenue__c,
        Do_we_have_cleaning_revenue__c ,Are_any_exhibitor_rates_contracted__c,
        Std_Exhibitor_City_Deco_Pricing__c, Management_Commissions__c, Facility_Commissions__c,
        Show_Cost_Revenue_Impact_year_over_year__c, Shared_Opportunities_from_show_to_show__c,
        Information_assistance_possibilities__c, Any_Significant_Show_Changes_YOY__c,
        Exhibitor_Sales_Marketing_Opportunities__c, Anything_else_that_we_should_know__c,
        Management_Freight_Details__c, Freight_Billing__c, Job_Numbers__c, Graphic_Sq_ft__c,
        Exhibitor_Freight_Weight__c, Carpet_Sq_Yards__c, Show_Name__c, Customs__c, Other__c,
        Overhead_Rigging__c, Cleaning__c, Utilities__c, Exhibit_Transportation__c, Freight__c,
        Decorating__c, Show_Management__c, Advance_Warehouse_Crated_ST__c, Advance_Warehouse_Crated_OT__c,
        Adv_WH_Special_Handling_ST__c, Adv_WH_Special_Handling_OT__c, Showsite_Crated_ST__c,
        Showsite_Crated_OT__c, Showsite_Special_Handling_ST__c, Showsite_Special_Handling_OT__c,
        I_D_Labor_ST__c, I_D_Labor_OT__c, I_D_Labor_DT__c, X9x10_Std_Booth_Carpet__c,
        Arm_Chair_Black_Diamond__c, X6_Skirted_Table__c, Net_Square_Footage__c, Exhibitor_Count__c,
        Opportunity__c, Budget_FY__c, wk1_Mon__c, wk1_Tue__c, wk1_Wed__c, wk1_Thu__c, wk1_Fri__c,
        wk1_Sat__c, wk1_Sun__c, wk2_Mon__c, wk2_Tue__c, wk2_Thu__c, wk2_Wed__c, wk2_Fri__c,
        wk2_Sat__c, wk2_Sun__c, wk3_Mon__c, wk3_Tue__c, wk3_Wed__c, wk3_Thu__c, wk3_Fri__c, wk3_Sat__c,
        wk3_Sun__c, wk4_Mon__c, wk4_Tue__c, wk4_Wed__c, wk1_Mon_Holiday__c, wk1_Tue_Holiday__c,
        wk1_Wed_Holiday__c, wk1_Thu_Holiday__c, wk1_Fri_Holiday__c, wk1_Sat_Holiday__c,
        wk1_Sun_Holiday__c, wk2_Mon_Holiday__c, wk2_Tue_Holiday__c, wk2_Wed_Holiday__c,
        wk2_Thu_Holiday__c, wk2_Fri_Holiday__c, wk2_Sat_Holiday__c, wk2_Sun_Holiday__c,
        wk3_Mon_Holiday__c, wk3_Tue_Holiday__c, wk3_Wed_Holiday__c, wk3_Thu_Holiday__c,
        wk3_Fri_Holiday__c, wk3_Sat_Holiday__c, wk3_Sun_Holiday__c, wk4_Mon_Holiday__c,
        wk4_Tue_Holiday__c, wk4_Wed_Holiday__c, Opportunity_Owner__c, Opportunity_Owner__r.Name,
        Acct_Mgmt_Producing__c, Acct_Mgmt_Producing__r.Name, Acct_Mgmt_Local_AE__c,
        Acct_Mgmt_Local_AE__r.Name, City__c, Venue_Facility__c, Halls__c,
        Prior_carry_forward_amortization_expense__c, Mgmt_Commission_Calculation__c,
        Facility_Commissions_Calculation__c, Material_Handling_Package__c, Total_Revenue__c,
        Year_of_Contract__c, Opportunity__r.Local_Account_Manager__c, Opportunity__r.Account_Manager__c,
        Opportunity__r.ownerId,Opportunity__r.Job_Cost_Actual__c, Opportunity__r.Reported_Revenue__c, Opportunity__r.Amount, Opportunity__r.Forecasted_Job_Cost__c
        From Budget_Years__r) From Opportunity o where Show_Campaign_ID__c = :campOpp.Show_Campaign_ID__c limit 5]);

       
I am trying to disable Advanced Currency Management. One of our admins turned it on in our instance and it is causing havoc in several Visualforce elements. I need it turned off. When I go to click disable and spools for about two minutes and then gives me this error: Your request exceeded the time limit for processing.

I've tried different browsers, different users,  both on and off our network, same error. Any ideas?
  • February 27, 2014
  • Like
  • 0

I need to compare Owner ID and Opportunity Team Member to a User ID in an Apex Class, if the ID's don't match they can't access the VF page. Any idea what this would like. Thanks in advance.

  • October 08, 2013
  • Like
  • 0

I have a custom link that executes a java script, the link takes you to a finance database. All the code seems to work fine, but the problem is we need only users who have access to the records (heirarchy) to have access to the link. Is there a way to add sharing rules to the coded link? Is there another way this can be accomplished?

  • October 04, 2013
  • Like
  • 0

Okay, so I was tasked to create a microsite for a customer. Basically this site is a duplicate of an existing force.com site. So, I cloned the home page to create a new site. Everything looks fine. However when I click on the "Home" button it takes me back to the original home page, effectively making it impossible to navigate back to the new home page. Any thoughts?

 

Thanks,  

  • August 08, 2012
  • Like
  • 0
So, I have a situation where I am trying to update a custom field that is a lookup to the User record. There is a csv sheet that is being uploaded to write to this field. It gives me the first and last name and that's it. I think this needs to be done in a trigger but I am unsure where to start. The look up field is called Prospect_Owner__c which sits on an object called Exhibitors. Any help would be greatly appreciate and would come with copious amounts of thank yous and good vibes!
  • November 13, 2018
  • Like
  • 0
Hello,
I created a very simple trigger to add a Note when a Lead is created. The Note is not getting added, what am I doing wrong? (Code below) Is it not working because the Lead is not yet created? With an After Insert this shouldn't matter though. Notes are turned on and are working to manually create them.
Thanks,
Ryan
trigger AddNote on Lead (after insert) {
	List<Note> addnte = new List<Note>();
        for(Lead lds : Trigger.new){
            Note addedntes = new Note();
            addedntes.ParentId = lds.Id;
            addedntes.Body = lds.Sales_Notes__c;
            addedntes.Title = 'Creation Note';
            addnte.add(addedntes);
        }
    if(addnte.size()>0){
        insert addnte;
    }
}

 
Hey all!
I have an old formula in our org and I'm trying to make sure it's doing what I think it's doing? If not we got some 'splaining to do. :) Anyway here's the code:
IF(AND(NOT(ISPICKVAL(Type , "General, Corporate Event, Exposition, Non-Revenue, Sub-Contract, Maritz" )),(RecordTypeId = "0123000000092IT")

&&
TODAY() >= DATE( IF(MONTH(Pipeline_Date__c)=12, YEAR(Pipeline_Date__c )+1, YEAR(Pipeline_Date__c )), IF(MONTH(Pipeline_Date__c)=12,1,MONTH(Pipeline_Date__c)+1), 15)),
Total_Revenue_Actual__c ,
Amount )

Okay, what do you think it's doing? I will speak about you very fondly if you can figure it out. Thanks!
I am trying to increase my code coverage from 59% to the required 75 for deployment. Below is my class.
 
public class ForecastedRevCon {
    public Integer size{get;set;}
    public Id oppId {get;set;}
    public Opportunity oppRec {get;set;}
    public String oppName {get; set;}
    
    public Decimal totExSelling {get;set;}
    public Decimal totNonExSelling {get;set;}
    public Decimal totSellingCredit {get;set;}
    public Decimal totExRevenue {get;set;}
    public Decimal totNonExRevenue {get;set;}
    public Decimal totOppRevenue {get;set;}
    
    public Decimal forRevTot {get;set;}
    
    public List<ForecastedRevConWrapper> listSellingCreditDet {get; set;}
    public List<ForecastedRevConWrapper> listRevenueCenter {get; set;}
    
    public List<ForecastedRevConWrapper> listSellingCreditDetDelete {get; set;}
    public List<ForecastedRevConWrapper> listRevenueCenterDelete {get; set;}
    
    public Map<String, Decimal> mapForcatedRevDet {get;set;}

    public ForecastedRevCon(ApexPages.StandardController stdCon) {
        
        oppId = Apexpages.currentPage().getParameters().get('oppId');
        init();
    }
    
    public void init(){
        Integer i = 0;
        
        forRevTot = 0;
        initRevDetMap();
        
        totExSelling = 0;
        totNonExSelling = 0;
        totSellingCredit = 0;
        totExRevenue = 0;
        totNonExRevenue = 0;
        totOppRevenue = 0;
        
        listSellingCreditDet = new List<ForecastedRevConWrapper>();
        listSellingCreditDetDelete = new List<ForecastedRevConWrapper>();
        
        listRevenueCenter = new List<ForecastedRevConWrapper>();
        listRevenueCenterDelete = new List<ForecastedRevConWrapper>();
        
        if(oppId !=null) {
            
            for(Opportunity op: [SELECT Id, Name,Event_Number__c  FROM Opportunity WHERE Id =: oppId]){
                oppRec = op;
                oppName = op.Name;
            }
            
            for(FreemanXP_Forecasted_Revenue_Detail__c FRD: [SELECT Id, 
                                                                   Sold_By__c,
                                                                   Amount__c, 
                                                                   Exclusive_Non__c,
                                                                   Non_Exclusive__c,
                                                                   Exclusive__c,
                                                                   Forecasted_Revenue_Type__c
                                                                   FROM FreemanXP_Forecasted_Revenue_Detail__c 
                                                                   WHERE Opportunity__c =: oppId order by createdDate]) {
                                                                        
                                                                        listSellingCreditDet.add(new ForecastedRevConWrapper(FRD, i));
                                                                        i++;
           }
           
           i = 0;
           for(FreemanXP_Revenue_Center_Details__c FRC: [SELECT Id,
                                                                Revenue_Center__c,
                                                                Opportunity__c,
                                                                Job_Number__c,
                                                                Exclusive__c,
                                                                Non_Exclusive__c,
                                                                Expo_Producing_Branch__c
                                                                FROM FreemanXP_Revenue_Center_Details__c
                                                                WHERE Opportunity__c =: oppId order by createdDate]){
                                                                    
                                                                    listRevenueCenter.add(new ForecastedRevConWrapper(FRC, i));
                                                                    i++;
           }
           calcTotal();
        }
        else{
            //handle if opportunity Id not supplied in param 
        }
    }
    
    public void initRevDetMap(){
        
        mapForcatedRevDet = new Map<String, Decimal>();
        
        /*mapForcatedRevDet.put('AlfordRevenue',0);
        mapForcatedRevDet.put('Cleaning',0);
        mapForcatedRevDet.put('ShowManagement',0);
        mapForcatedRevDet.put('Decorating',0);
        mapForcatedRevDet.put('Freight',0);
        mapForcatedRevDet.put('ExhibitTransportation',0);
        mapForcatedRevDet.put('Utilities',0);
        mapForcatedRevDet.put('Electrical',0);
        mapForcatedRevDet.put('OverheadRigging',0);
        mapForcatedRevDet.put('Technology',0);
        mapForcatedRevDet.put('Other',0);
        mapForcatedRevDet.put('Customs',0);
        mapForcatedRevDet.put('Alford',0);
        mapForcatedRevDet.put('AudioVisual',0);
        mapForcatedRevDet.put('DigitalServices',0);
        mapForcatedRevDet.put('Encore',0);
        mapForcatedRevDet.put('Entertainment',0);
        mapForcatedRevDet.put('ExperienceDesign',0);
        mapForecatedRevDet.put('ExhibitSurveys',0);
        mapForcatedRevDet.put('ProductionManagement',0);
        mapForcatedRevDet.put('Sponsorship',0);
        mapForcatedRevDet.put('SpecialEvents',0);
        mapForcatedRevDet.put('StrategyandUK',0);*/
        
        mapForcatedRevDet.put('Alford',0);
        mapForcatedRevDet.put('AudioVisual',0);
        mapForcatedRevDet.put('Cleaning',0);
        mapForcatedRevDet.put('CustomConstructionRevenue',0);
        mapForcatedRevDet.put('Decorating',0);
        mapForcatedRevDet.put('Electrical',0);
        mapForcatedRevDet.put('Encore',0);
        mapForcatedRevDet.put('ExhibitTransportation',0);
        mapForcatedRevDet.put('Freight',0);
        mapForcatedRevDet.put('FXPDigitalServices',0);
        mapForcatedRevDet.put('FXPEntertainment',0);
        mapForcatedRevDet.put('FXPExhibitSurveys',0);
        mapForcatedRevDet.put('FXPExperienceDesign',0);
        mapForcatedRevDet.put('FXPProductionManagementFee',0);
        mapForcatedRevDet.put('FXPSpecialEvents',0);
        mapForcatedRevDet.put('FXPStrategy',0);
        mapForcatedRevDet.put('Other',0);
        mapForcatedRevDet.put('OverheadRigging',0);
        mapForcatedRevDet.put('SeattleManagementFees',0);
        mapForcatedRevDet.put('ShowManagement',0);
        mapForcatedRevDet.put('FXPSponsorshipRevenue',0);
        mapForcatedRevDet.put('Technology',0);
        mapForcatedRevDet.put('UK',0);
        mapForcatedRevDet.put('Utilities',0);
    }

    public PageReference addRowSellingCredit() {
        Integer newindex = 0;
        
        String recType = Apexpages.currentPage().getParameters().get('recType');
        
        Apexpages.currentPage().getParameters().put('oppId', oppId );
        
        if(recType.equals('selling')){
            for(ForecastedRevConWrapper fx : listSellingCreditDet){
            newindex = fx.index;
            }
            newindex++;
        
            if(listSellingCreditDet != null){
                listSellingCreditDet.add(new ForecastedRevConWrapper(new FreemanXP_Forecasted_Revenue_Detail__c(Opportunity__c =oppId), newindex));
            }
        }
        else {
            for(ForecastedRevConWrapper fx : listRevenueCenter){
                newindex = fx.index;
            }
            newindex++;
            
            if(listRevenueCenter != null){
                listRevenueCenter.add(new ForecastedRevConWrapper(new FreemanXP_Revenue_Center_Details__c(Opportunity__c =oppId), newindex));
            }
        }
        return null;
    }
    
    public Pagereference deleteRowSellingCredit() {
        Integer index = Integer.valueOf(Apexpages.currentPage().getParameters().get('index'));
        String recType = Apexpages.currentPage().getParameters().get('recType');
        Integer delIndex = 0;
        
        if(recType.equals('selling')) {
            
            if(listSellingCreditDet.size() == 0){
                return null;
            }
                    
            for(Integer i=0;i<listSellingCreditDet.size(); i++){
                
                ForecastedRevConWrapper fx = listSellingCreditDet.get(i);
                if(fx.index == index){
                    fx.isDelete = true;
                    delIndex = i;
                    listSellingCreditDetDelete.add(fx);  
                }
            }
            listSellingCreditDet.remove(delIndex);
        }
        else {
            
            if(listRevenueCenter.size() == 0){
                return null;
            }
                    
            for(Integer i=0;i<listRevenueCenter.size(); i++){
                
                ForecastedRevConWrapper fx = listRevenueCenter.get(i);
                if(fx.index == index){
                    fx.isDelete = true;
                    delIndex = i;
                    listRevenueCenterDelete.add(fx); 
                }
            }
            listRevenueCenter.remove(delIndex);
        }
        
        calcTotal();
        
        return null;
    }
    
    public PageReference saveForecastedRev(){
        
        /*if(totSellingCredit != totOppRevenue){
            Apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Error, Label.Selling_Credit_Save_Validation);
            Apexpages.addmessage(msg);
            return null;
        }*/
        
        List<FreemanXP_Forecasted_Revenue_Detail__c> listRecordUpsert = new List<FreemanXP_Forecasted_Revenue_Detail__c>();
        List<FreemanXP_Forecasted_Revenue_Detail__c> listRecordDelete = new List<FreemanXP_Forecasted_Revenue_Detail__c>();
        
        List<FreemanXP_Revenue_Center_Details__c> listRevenueUpsert = new List<FreemanXP_Revenue_Center_Details__c>();
        List<FreemanXP_Revenue_Center_Details__c> listRevenueDelete = new List<FreemanXP_Revenue_Center_Details__c>();
        
        for(ForecastedRevConWrapper fx : listSellingCreditDet){
            
            if(/*fx.wrapRecord.amount__c !=null && */!fx.isDelete) {
                listRecordUpsert.add(fx.wrapRecord);
            }
        }
        
        for(ForecastedRevConWrapper fx : listSellingCreditDetDelete){
            
            if(fx.isDelete && fx.wrapRecord.Id != null) {
                listRecordDelete.add(fx.wrapRecord);
            }
        }
        
        for(ForecastedRevConWrapper fx : listRevenueCenter){
            
            if(fx.revCenter.Revenue_Center__c !=null && !fx.isDelete) {
                listRevenueUpsert.add(fx.revCenter);
            }
        }
        
        for(ForecastedRevConWrapper fx : listRevenueCenterDelete){
            
            if(fx.isDelete && fx.revCenter.Id != null) {
                listRevenueDelete.add(fx.revCenter);
            }
        }
        
        try{
            if(!listRecordUpsert.isEmpty()){
                upsert listRecordUpsert;
            }
            if(!listRecordDelete.isEmpty()){
                delete listRecordDelete;
            }
            if(!listRevenueUpsert.isEmpty()){
                  
                    //if(listRevenueUpsert.get(0).Job_Number__c != null && listRevenueUpsert.get(0).Job_Number__c.length() <= 6){
                        //oppRec.Event_Number__c = listRevenueUpsert.get(0).Job_Number__c;
                    //}
                  for(FreemanXP_Revenue_Center_Details__c rcd: listRevenueUpsert){
                    if(rcd.Expo_Producing_Branch__c){
                      oppRec.Event_Number__c = rcd.Job_Number__c;
                    }
                  }
              upsert listRevenueUpsert;
            }
            if(!listRevenueDelete.isEmpty()){
                delete listRevenueDelete;
            }
            
            update oppRec;
            
            init();
            
            Apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Record(s) Saved Successfully!');
            Apexpages.addmessage(msg);
            return new PageReference('/'+oppRec.Id);
        }
        catch(Exception ex){
            Apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Error,ex.getMessage());
            Apexpages.addmessage(msg);
        }
        
        return null;
    }
    
    public PageReference calcTotal(){
        
        initRevDetMap();
        forRevTot = 0;
        totExSelling = 0;
        totNonExSelling = 0;
        totSellingCredit = 0;
        totExRevenue = 0;
        totNonExRevenue = 0;
        totOppRevenue = 0;
        
        for(ForecastedRevConWrapper fx : listSellingCreditDet){
            try {
                totNonExSelling += (fx.wrapRecord.Non_Exclusive__c !=null ? fx.wrapRecord.Non_Exclusive__c: 0);
                totExSelling += (fx.wrapRecord.Exclusive__c !=null ? fx.wrapRecord.Exclusive__c: 0);
                
                decimal val = (fx.wrapRecord.Non_Exclusive__c !=null ? fx.wrapRecord.Non_Exclusive__c: 0) + (fx.wrapRecord.Exclusive__c !=null ? fx.wrapRecord.Exclusive__c: 0);
                totSellingCredit += val;
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Cleaning')){
                    updateValue('Cleaning', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Decorating')){
                    updateValue('Decorating', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Audio Visual')){
                    updateValue('AudioVisual', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Experience Design')){
                    updateValue('FXPExperienceDesign', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Show Management')){
                    updateValue('ShowManagement', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Freight')){
                    updateValue('Freight', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Exhibit Transportation')){
                    updateValue('ExhibitTransportation', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Utilities')){
                    updateValue('Utilities', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Electrical')){
                    updateValue('Electrical', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Overhead Rigging')){
                    updateValue('OverheadRigging', val);
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Technology')){
                    updateValue('Technology', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Other')){
                    updateValue('Other', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Custom Construction Revenue')){
                    updateValue('CustomConstructionRevenue', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Alford')){
                    updateValue('Alford', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Digital Services')){
                    updateValue('FXPDigitalServices', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Encore')){
                    updateValue('Encore', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Entertainment')){
                    updateValue('FXPEntertainment', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Exhibit Surveys')){
                    updateValue('FXPExhibitSurveys', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Production Management Fee')){
                    updateValue('FXPProductionManagementFee', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Sponsorship Revenue')){
                    updateValue('FXPSponsorshipRevenue', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Special Events')){
                    updateValue('FXPSpecialEvents', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('FXP – Strategy')){
                    updateValue('FXPStrategy', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('UK')){
                    updateValue('UK', val); 
                }
                if(fx.wrapRecord.Forecasted_Revenue_Type__c.equals('Seattle Management Fees')){
                    updateValue('SeattleManagementFees', val); 
                }
            }
            catch(Exception ex){}
        }
        
         for(ForecastedRevConWrapper fx : listRevenueCenter){
            
            try {
                
                totNonExRevenue += (fx.revCenter.Non_Exclusive__c !=null ? fx.revCenter.Non_Exclusive__c: 0);
                totExRevenue += (fx.revCenter.Exclusive__c !=null ? fx.revCenter.Exclusive__c: 0);
                
                decimal val = (fx.revCenter.Non_Exclusive__c !=null ? fx.revCenter.Non_Exclusive__c: 0) + (fx.revCenter.Exclusive__c !=null ? fx.revCenter.Exclusive__c: 0);
                totOppRevenue += val;
                                
             }
            catch(Exception ex){}
        }
        
        for(Decimal val: mapForcatedRevDet.values()){
            forRevTot += val;
        }
        
        return null;
    }

    public void updateValue(String key, Decimal v){
        Decimal ov = mapForcatedRevDet.get(key);
         ov += v;
         mapForcatedRevDet.put(key, ov);
    }
    
    public PageReference updateMainJob(){
      Integer index = Integer.valueOf(Apexpages.currentPage().getParameters().get('index'));
      
      
      List<FreemanXP_Revenue_Center_Details__c> listRev = new List<FreemanXP_Revenue_Center_Details__c>();
      
      if(listRevenueCenter.size() == 0){
        return null;
      }
              
      for(Integer i=0;i<listRevenueCenter.size(); i++){
 
          ForecastedRevConWrapper fx = listRevenueCenter.get(i);
          FreemanXP_Revenue_Center_Details__c rc = fx.revCenter;
          if(fx.index == index){
            rc.Expo_Producing_Branch__c = true;
            oppRec.Event_Number__c = rc.Job_Number__c;
          }
          else{
            rc.Expo_Producing_Branch__c = false;
          }
          listRev.add(rc);
      }
      
      try{
        if(!listRev.isEmpty()){
          upsert listRev;
          //oppRec.Event_Number__c = rc.Job_Number__c;
          update oppRec;
          init();
        }
      }
      catch(Exception ex){
         Apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Error,ex.getMessage());
         Apexpages.addmessage(msg);
      }
      return null;
    }
        public class ForecastedRevConWrapper {
            public FreemanXP_Forecasted_Revenue_Detail__c wrapRecord {get;set;}
            public FreemanXP_Revenue_Center_Details__c revCenter {get;set;}
            public integer index {get;set;}
            public Boolean isDelete {get;set;}
            
            public ForecastedRevConWrapper(FreemanXP_Forecasted_Revenue_Detail__c obj, Integer index){
              this.wrapRecord = obj;
              this.index = index;
              this.isDelete = false;
            }
            
            public ForecastedRevConWrapper(FreemanXP_Revenue_Center_Details__c obj, Integer index){
              this.revCenter = obj;
              this.index = index;
              this.isDelete = false;
            }
     
       }
}
And here is my test Class:
@isTest
private class ForecastedRevConTest {
    
    private static Opportunity opp;
    
    static testMethod void myUnitTest() {
        
        createTestData();
        
        Test.startTest();
           ApexPages.currentPage().getParameters().put('id',opp.Id);
           
           ApexPages.StandardController std = new ApexPages.Standardcontroller(opp);
           
           ForecastedRevCon controller = new ForecastedRevCon(std);
           
           ApexPages.currentPage().getParameters().put('recType','selling');
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           ApexPages.currentPage().getParameters().put('recType','rev');
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           
           ApexPages.currentPage().getParameters().put('index',1+'');
           ApexPages.currentPage().getParameters().put('recType','selling');
           
           controller.deleteRowSellingCredit();
           ApexPages.currentPage().getParameters().put('index',1+'');
           ApexPages.currentPage().getParameters().put('recType','rev');
           
           controller.deleteRowSellingCredit();
           
           controller.saveForecastedRev();
           
           
        Test.stopTest();
    }
    
    static testMethod void myUnitTestB() {
        
        createTestData();
        
        Test.startTest();
           ApexPages.currentPage().getParameters().put('id',opp.Id);
           
           ApexPages.StandardController std = new ApexPages.Standardcontroller(opp);
           
           ForecastedRevCon controller = new ForecastedRevCon(std);
           
           ApexPages.currentPage().getParameters().put('recType','selling');
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           ApexPages.currentPage().getParameters().put('recType','rev');
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           controller.addRowSellingCredit();
           
           ApexPages.currentPage().getParameters().put('index',2+'');
           ApexPages.currentPage().getParameters().put('recType','selling');
           
           controller.deleteRowSellingCredit();
           ApexPages.currentPage().getParameters().put('index',2+'');
           ApexPages.currentPage().getParameters().put('recType','rev');
           
           controller.deleteRowSellingCredit();
           
           controller.saveForecastedRev();
           
           
        Test.stopTest();
    }
        
    public static void createTestData(){
        Id rtId;
        Map<String, Schema.SObjectType> sObjectMap = Schema.getGlobalDescribe() ;
        Schema.SObjectType s = sObjectMap.get('Opportunity') ; // getting Sobject Type
        Schema.DescribeSObjectResult resSchema = s.getDescribe() ;
        Map<String,Schema.RecordTypeInfo> recordTypeInfo = resSchema.getRecordTypeInfosByName(); //getting all Recordtype for the Sobject
        rtId = recordTypeInfo.get('Exposition Services').getRecordTypeId();//particular RecordId by  Name
        
        Account a = new Account(Name = 'Test Account', 
                        Type = 'test type', 
                        fax='123456789x23', 
                        BillingStreet = 'test Street', 
                        BillingCity = 'test City', 
                        BillingCountry = 'test Country', 
                        BillingState = 'GA', 
                        BillingPostalCode = '23456', 
                        Phone = '123456789x24', 
                        Customer_Number__c = '123456' );                            
        insert a;                                         
            
        opp = new Opportunity(Name = 'Test Opp',
                                        RecordTypeId = rtId,
                                        AccountId = a.Id,
                                        Type = 'test type',
                                        New_Existing__c = 'New',
                                        CloseDate = date.today(),
                                        StageName = 'Proposed',
                                        Show_Management_Revenue_Est__c = 15100,
                                        Producing_Branch__c = 'FDC',/* ANAHEIM (128)',*/
                                        /*Show_Opening_Date__c = Date.today().addDays(5),*/
                                        Probability = 25,
                                        Event_Number__c = '234567'
                                        );
        insert opp;
        
    }
}
Any help would be greatly appreciated! As always it's urgent. :) Thanks!

 
  • December 17, 2016
  • Like
  • 0
I'm sure this is pretty standard, but we have a major problem as we're in the middle of a deployment. I got this error when trying to deploy this test class: System.QueryException: Non-Selective Query against large object type. Consider an indexed filter. I need to adjust this so I can get this deployed. Any ideas as to how to index this line so I can get it to pass. Any help would be greatly appreciated. Thanks! Below is the portion of code in question.

 Opportunity campOpp = [Select Campaign.Parent.Id, Show_Campaign_ID__c from opportunity where id = :o4.id];
        System.debug('campOpp ->' + campOpp);
      
        System.currentPageReference().getParameters().put('opportunityId', o4.Id);
        List<Opportunity> listOpps = new List<Opportunity>([Select o.AccountId, o.Show_Campaign_ID__c,
        o.Campaign.Show_Close_Date__c, Name, Account_Manager__r.Name, (Select Id,  
        IsDeleted, Name, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp,
        LastActivityDate, ConnectionReceivedId, ConnectionSentId, Opp_Show_Name__c,
        Opp_Owner__c, Opp_Acct_Management_Producing__c, Opp_Acct_Management_Local_AE__c,
        Opp_Job_Number__c, Opp_Facility_City__c, Opp_Facility__c, Opp_Exhibit_Hall__c,
        Opp_Square_Footage__c, Opp_Exhibitor_Count__c, Opp_Producing_Branch__c, Opp_Show_Move_In__c,
        Opp_Show_Move_Out__c, Opp_Show_Opening_Date__c, Opp_Show_Close_Date__c,
        Do_we_have_overhead_rigging__c, Do_we_have_electrical_revenue__c,
        Do_we_have_cleaning_revenue__c ,Are_any_exhibitor_rates_contracted__c,
        Std_Exhibitor_City_Deco_Pricing__c, Management_Commissions__c, Facility_Commissions__c,
        Show_Cost_Revenue_Impact_year_over_year__c, Shared_Opportunities_from_show_to_show__c,
        Information_assistance_possibilities__c, Any_Significant_Show_Changes_YOY__c,
        Exhibitor_Sales_Marketing_Opportunities__c, Anything_else_that_we_should_know__c,
        Management_Freight_Details__c, Freight_Billing__c, Job_Numbers__c, Graphic_Sq_ft__c,
        Exhibitor_Freight_Weight__c, Carpet_Sq_Yards__c, Show_Name__c, Customs__c, Other__c,
        Overhead_Rigging__c, Cleaning__c, Utilities__c, Exhibit_Transportation__c, Freight__c,
        Decorating__c, Show_Management__c, Advance_Warehouse_Crated_ST__c, Advance_Warehouse_Crated_OT__c,
        Adv_WH_Special_Handling_ST__c, Adv_WH_Special_Handling_OT__c, Showsite_Crated_ST__c,
        Showsite_Crated_OT__c, Showsite_Special_Handling_ST__c, Showsite_Special_Handling_OT__c,
        I_D_Labor_ST__c, I_D_Labor_OT__c, I_D_Labor_DT__c, X9x10_Std_Booth_Carpet__c,
        Arm_Chair_Black_Diamond__c, X6_Skirted_Table__c, Net_Square_Footage__c, Exhibitor_Count__c,
        Opportunity__c, Budget_FY__c, wk1_Mon__c, wk1_Tue__c, wk1_Wed__c, wk1_Thu__c, wk1_Fri__c,
        wk1_Sat__c, wk1_Sun__c, wk2_Mon__c, wk2_Tue__c, wk2_Thu__c, wk2_Wed__c, wk2_Fri__c,
        wk2_Sat__c, wk2_Sun__c, wk3_Mon__c, wk3_Tue__c, wk3_Wed__c, wk3_Thu__c, wk3_Fri__c, wk3_Sat__c,
        wk3_Sun__c, wk4_Mon__c, wk4_Tue__c, wk4_Wed__c, wk1_Mon_Holiday__c, wk1_Tue_Holiday__c,
        wk1_Wed_Holiday__c, wk1_Thu_Holiday__c, wk1_Fri_Holiday__c, wk1_Sat_Holiday__c,
        wk1_Sun_Holiday__c, wk2_Mon_Holiday__c, wk2_Tue_Holiday__c, wk2_Wed_Holiday__c,
        wk2_Thu_Holiday__c, wk2_Fri_Holiday__c, wk2_Sat_Holiday__c, wk2_Sun_Holiday__c,
        wk3_Mon_Holiday__c, wk3_Tue_Holiday__c, wk3_Wed_Holiday__c, wk3_Thu_Holiday__c,
        wk3_Fri_Holiday__c, wk3_Sat_Holiday__c, wk3_Sun_Holiday__c, wk4_Mon_Holiday__c,
        wk4_Tue_Holiday__c, wk4_Wed_Holiday__c, Opportunity_Owner__c, Opportunity_Owner__r.Name,
        Acct_Mgmt_Producing__c, Acct_Mgmt_Producing__r.Name, Acct_Mgmt_Local_AE__c,
        Acct_Mgmt_Local_AE__r.Name, City__c, Venue_Facility__c, Halls__c,
        Prior_carry_forward_amortization_expense__c, Mgmt_Commission_Calculation__c,
        Facility_Commissions_Calculation__c, Material_Handling_Package__c, Total_Revenue__c,
        Year_of_Contract__c, Opportunity__r.Local_Account_Manager__c, Opportunity__r.Account_Manager__c,
        Opportunity__r.ownerId,Opportunity__r.Job_Cost_Actual__c, Opportunity__r.Reported_Revenue__c, Opportunity__r.Amount, Opportunity__r.Forecasted_Job_Cost__c
        From Budget_Years__r) From Opportunity o where Show_Campaign_ID__c = :campOpp.Show_Campaign_ID__c limit 5]);

       
I am trying to disable Advanced Currency Management. One of our admins turned it on in our instance and it is causing havoc in several Visualforce elements. I need it turned off. When I go to click disable and spools for about two minutes and then gives me this error: Your request exceeded the time limit for processing.

I've tried different browsers, different users,  both on and off our network, same error. Any ideas?
  • February 27, 2014
  • Like
  • 0

I need to compare Owner ID and Opportunity Team Member to a User ID in an Apex Class, if the ID's don't match they can't access the VF page. Any idea what this would like. Thanks in advance.

  • October 08, 2013
  • Like
  • 0

I have a custom link that executes a java script, the link takes you to a finance database. All the code seems to work fine, but the problem is we need only users who have access to the records (heirarchy) to have access to the link. Is there a way to add sharing rules to the coded link? Is there another way this can be accomplished?

  • October 04, 2013
  • Like
  • 0