• Joshua Anderson 17
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 14
    Replies
I have been trying to push my deployment that consist of a Apex class and the test class for it (test class applies 95% code coverage). When I attempt to push this I get "Code Coverage Failure - Your code coverage is 0%. You need at least 75% coverage to complete this deployment." I am very confused as for components I am at 21/22 which gives me 95% code coverage. I have removed any kind of duplication errors and my overall code is at 80%. 

Any thoughts on what I might be doing wrong or missing? 
I am trying to update a date field on the Account object when two roll up summaries (Total_Opportunities_Won__c & Active_Opportunities__c) enter 0. Currently our process is that we have two roll up summaries that feed from the Opportunity object and then we have 3 scheduled apex classes to update the status. What I am needing to accomplish is a way to update a date field on the Account object when both the roll up summaries equal 0. Then if the roll up summary for Active_Opportunities__c increases to 1 or greater to put todays date. Was wondering if someone might be able to help the newbie with this? 
global class DailyAccountProcessorProspect implements Schedulable {

    global void execute(SchedulableContext ctx) {
        List<Account> myList = [SELECT Active_Opportunities__c,Id,Total_Opportunities_Won__c FROM Account WHERE Total_Opportunities_Won__c = 0 AND Active_Opportunities__c = 0];
        
        if(!myList.isEmpty()) {
            for(Account l: myList) {
                l.Customer_Type__c = 'Prospect';
            }
            update myList;
        }
    }
}
global class DailyAccountProcessorFormer implements Schedulable {

    global void execute(SchedulableContext ctx) {
        List<Account> myList = [SELECT Active_Opportunities__c,Id,Total_Opportunities_Won__c FROM Account WHERE Total_Opportunities_Won__c >= 1 AND Active_Opportunities__c = 0];
        
        if(!myList.isEmpty()) {
            for(Account l: myList) {
                l.Customer_Type__c = 'Former Customer';
            }
            update myList;
        }
    }
}
global class DailyAccountProcessorCurrent implements Schedulable {

    global void execute(SchedulableContext ctx) {
        List<Account> myList = [SELECT Active_Opportunities__c,Id,Total_Opportunities_Won__c FROM Account WHERE Total_Opportunities_Won__c >= 1 AND Active_Opportunities__c = 1];
        
        if(!myList.isEmpty()) {
            for(Account l: myList) {
                l.Customer_Type__c = 'Current Client';
            }
            update myList;
        }
    }
}



 
So I have two rollup summaries (Total_Opportunities_Won__c && Active_Opportunities__c) that feed into the Account object from the opportunities object. I was trying to update a picklist (Customer_Type__c)
  • Former Client = Total_Oppotunities_Won__c >= 1 && Active_Opportunities__c = 0
  • Current Client = Total_Oppotunities_Won__c > 0 && Active_Opportunities__c = 1
  • Prospect = Total_Oppotunities_Won__c = 0 && Active_Opportunities__c = 0
I couldn't figure out how to update field via process builder so I turned this field into a formula(text). It looks like they are now wanting a workflow/process builder to update any contacts associated with that account so I tried to schedule an Apex Class to run nightly to update this information. I was able to save the Apex but when I scheduled this Apex to test nothing seemed to update. Was wondering if anyone had any idea what I might be donig wrong in my apex class or any recommendations? 
 
global class DailyContactProcessor implements Schedulable {

    global void execute(SchedulableContext ctx) {
        List<Contact> myList = [Select Id, Contact_Type__c from Contact where Account_Status__c = 'Former Client'];
        
        if(!myList.isEmpty()) {
            for(Contact l: myList) {
                l.Customer_Type__c = 'Former Customer';
            }
            update myList;
        }
    }
}
In the Apex Class I created a formula field (Contact.Account_Status__c) which pulls from Account.Customer_Type__c. It is supposed to pull a list of all contacts that show 'Former Client' and then update 
 
I am looking to update a lookup field on the opportunity after a lead has been converted. Not sure if this is possible so I was first wondering if we could even do this. I currently have mapped the fields with a formula so that the lead ID shows on the opportunity but after the lead is converted the lookup will not allow me to select a converted lead. 

Does anyone have any suggestions to try and get me on the right track? 
I am trying to update a date field on the Account object when two roll up summaries (Total_Opportunities_Won__c & Active_Opportunities__c) enter 0. Currently our process is that we have two roll up summaries that feed from the Opportunity object and then we have 3 scheduled apex classes to update the status. What I am needing to accomplish is a way to update a date field on the Account object when both the roll up summaries equal 0. Then if the roll up summary for Active_Opportunities__c increases to 1 or greater to put todays date. Was wondering if someone might be able to help the newbie with this? 
global class DailyAccountProcessorProspect implements Schedulable {

    global void execute(SchedulableContext ctx) {
        List<Account> myList = [SELECT Active_Opportunities__c,Id,Total_Opportunities_Won__c FROM Account WHERE Total_Opportunities_Won__c = 0 AND Active_Opportunities__c = 0];
        
        if(!myList.isEmpty()) {
            for(Account l: myList) {
                l.Customer_Type__c = 'Prospect';
            }
            update myList;
        }
    }
}
global class DailyAccountProcessorFormer implements Schedulable {

    global void execute(SchedulableContext ctx) {
        List<Account> myList = [SELECT Active_Opportunities__c,Id,Total_Opportunities_Won__c FROM Account WHERE Total_Opportunities_Won__c >= 1 AND Active_Opportunities__c = 0];
        
        if(!myList.isEmpty()) {
            for(Account l: myList) {
                l.Customer_Type__c = 'Former Customer';
            }
            update myList;
        }
    }
}
global class DailyAccountProcessorCurrent implements Schedulable {

    global void execute(SchedulableContext ctx) {
        List<Account> myList = [SELECT Active_Opportunities__c,Id,Total_Opportunities_Won__c FROM Account WHERE Total_Opportunities_Won__c >= 1 AND Active_Opportunities__c = 1];
        
        if(!myList.isEmpty()) {
            for(Account l: myList) {
                l.Customer_Type__c = 'Current Client';
            }
            update myList;
        }
    }
}



 
I am looking to update a lookup field on the opportunity after a lead has been converted. Not sure if this is possible so I was first wondering if we could even do this. I currently have mapped the fields with a formula so that the lead ID shows on the opportunity but after the lead is converted the lookup will not allow me to select a converted lead. 

Does anyone have any suggestions to try and get me on the right track?