• Renee Nicholus
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Receiving this error when trying to schedule this class.  

line: 6, Column: 41
Dependent class is invalid and needs recompilation: Class UpdateCSBHSchedulable : Static method cannot be referenced from a non static context: void updateCurrentStatusBusinessHours.updateBusinessHours()

I added the bold when I got an apex time limit exceeded error when trying to run - I read that I needed to change to a future method, but I wasn't sure of everything that needed to be changed. Are there other parts I need to adjust to make this a valid future method, and clear the 
"Static method cannot be referenced from a non static context" error?

Class below:

public class updateCurrentStatusBusinessHours
{
    @future
    public static void updateBusinessHours()
{
    
     List<SBQQ__Quote__c> SBQQs = [SELECT Approval_Status_Start_Time__c, Status_Start_Time__c FROM SBQQ__Quote__c 
                                  WHERE  RecordTypeId IN ('012U00000001s4PIAQ','0120B0000001w3OQAQ', '0120B0000001w3JQAQ','012U0000000EB4BIAW') AND
                                         Opportunity_Stage__c != 'Closed - Won (100%)' AND Approval_Status_Start_Time__c != null AND Status_Start_Time__c != null];        
     System.debug(SBQQs);
        
        BusinessHours BusinessHoursId = [SELECT Id FROM BusinessHours WHERE IsActive=true AND name= 'CSS' LIMIT 1];
     for (SBQQ__Quote__c SBQQ : SBQQs)
    { 
        //Input
        Datetime ASST = SBQQ.Approval_Status_Start_Time__c ;
        Datetime SST  = SBQQ.Status_Start_Time__c;
        
        //Approval Status Calc
        Decimal ASSTdiffHours = BusinessHours.diff(businessHoursId.id, ASST, system.now());
        Decimal ASSTdiff = ASSTdiffHours/3600000;  // converting milliseconds into Hour
        
        //Status Calc
        Decimal SSTdiffHours = BusinessHours.diff(businessHoursId.id, SST, system.now());
        Decimal SSTdiff = SSTdiffHours/3600000;  // converting milliseconds into Hours
    
        //Output
        SBQQ.Approval_Status_Business_Hours_CST_SF__c = ASSTdiff;
        SBQQ.Status_Business_Hours_CST_SF__c = SSTdiff;
        SBQQ.Last_Current_Status_Run_Time__c = system.now();
    }
        //Update all records
        update SBQQs;
        
  }
}
Getting the subject line error when validating my test class. I'm not a developer (someone from SF CS team that no longer works there helped me write this initially) so I think this is a simple fix, but I couldn't figure out how to update it based on the examples I saw.  Any help would be appreciated. Thanks!


@isTest
private class BusinessHoursTest {
    
    public static testMethod void BusinessHours(){        
        //Delcare var
        Decimal diff;
        
        //Test QFH data
        Quote_Field_History__c QFH = new Quote_Field_History__c();
        QFH.Quote__c = 'a2Lm00000007mTYEAY';
        QFH.Start_Time__c = system.now();
        QFH.Stop_Time__c = (system.now()+5);
        insert QFH;               
        
        
        system.debug('Inserting QFH with vaild QFH.Stop_Time__c value');
        
        BusinessHours BusinessHoursId = [SELECT Id FROM BusinessHours WHERE IsActive=true AND name= 'CS];
        QFH = [select ID, Stop_Time__c, Name from Quote_Field_History__c where Id = 'a2Lm00000007mTYEAY'];
        system.assert(QFH.Stop_Time__c != Null);
    }
}
This rule isn't firing unless there is a date in the Training_Request_Date__c field, however, I want it to fire even if the field is blank. From what I see, it should be firing if that field is blank. Only if the field has today's date, it should not fire. Any ideas?

AND(  
RecordType.Name = " Test Opportunity Record Type",   
ISPICKVAL (StageName, "Closed - Won (100%)"), ISPICKVAL(Sales_Type__c,"New EST") ||  
ISPICKVAL(Sales_Type__c,"New EST/DRP") ||  
ISPICKVAL(Sales_Type__c,"New Add-On"), 
NOT(ISPICKVAL( Order_Type__c , "Renewal Contract")), 
NOT(Training_Request_Date__c == TODAY()),
Account.Field_Service_Territory__r.Name = "E-1A" ||
Account.Field_Service_Territory__r.Name = "E-1B" ||
Account.Field_Service_Territory__r.Name = "E-1C")
Getting the subject line error when validating my test class. I'm not a developer (someone from SF CS team that no longer works there helped me write this initially) so I think this is a simple fix, but I couldn't figure out how to update it based on the examples I saw.  Any help would be appreciated. Thanks!


@isTest
private class BusinessHoursTest {
    
    public static testMethod void BusinessHours(){        
        //Delcare var
        Decimal diff;
        
        //Test QFH data
        Quote_Field_History__c QFH = new Quote_Field_History__c();
        QFH.Quote__c = 'a2Lm00000007mTYEAY';
        QFH.Start_Time__c = system.now();
        QFH.Stop_Time__c = (system.now()+5);
        insert QFH;               
        
        
        system.debug('Inserting QFH with vaild QFH.Stop_Time__c value');
        
        BusinessHours BusinessHoursId = [SELECT Id FROM BusinessHours WHERE IsActive=true AND name= 'CS];
        QFH = [select ID, Stop_Time__c, Name from Quote_Field_History__c where Id = 'a2Lm00000007mTYEAY'];
        system.assert(QFH.Stop_Time__c != Null);
    }
}
This rule isn't firing unless there is a date in the Training_Request_Date__c field, however, I want it to fire even if the field is blank. From what I see, it should be firing if that field is blank. Only if the field has today's date, it should not fire. Any ideas?

AND(  
RecordType.Name = " Test Opportunity Record Type",   
ISPICKVAL (StageName, "Closed - Won (100%)"), ISPICKVAL(Sales_Type__c,"New EST") ||  
ISPICKVAL(Sales_Type__c,"New EST/DRP") ||  
ISPICKVAL(Sales_Type__c,"New Add-On"), 
NOT(ISPICKVAL( Order_Type__c , "Renewal Contract")), 
NOT(Training_Request_Date__c == TODAY()),
Account.Field_Service_Territory__r.Name = "E-1A" ||
Account.Field_Service_Territory__r.Name = "E-1B" ||
Account.Field_Service_Territory__r.Name = "E-1C")