• Derrick Abbey 9
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hello,

I have a scheduled apex class that uses the Last Modified Date in an SOQL query.  My problem is: when I create the Apex test class, I can't set the Last Modified Date to be in the past on the record that I am inserting for my test.  But when I do the insert it updates the Last Modified Date to the current date/time.  Does anyone know of a way of creating a test record where the created date and last modified date will be in the past?
Hi Everyone,

I'm new to Apex and I'm trying to schedule a class that I've written.  I'm going into Setup > Develop > Apex Classes and clicking on the "Schedule Apex button.  When I select my class I get an error that says "You must select an Apex class that implements the Schedulable interface."  The thing is, I thought I followed the develper documentation correctly in setting this up.  I can't figure out why it's giving me this error.  Can anyone offer some assistance?  Here's my class:
global class autoRenewalOpps Implements Schedulable {
    global void execute(SchedulableContext sc) {
    	aRopps();   
    }
    public void aRopps() {
        //Create list of renewal opportunities to close
    	List<Opportunity> renewalOpps = [SELECT StageName, Type
			FROM Opportunity
			WHERE RecordTypeId = '012S00000000klc'
			AND IsClosed = False
			AND Type = 'Renewal'
			AND CloseDate < LAST_N_WEEKS:2
			AND LastActivityDate < LAST_N_WEEKS:2
			];
        
    	//Loop through opportunities changing the type and stage
    	for (Opportunity opp : renewalOpps) {
        	opp.type = 'Auto-Renewal';
        	opp.StageName = 'Closed Won';
		}
        
        //Update the opportunities
        update renewalOpps;
    }
}
And here's the error I get when trying to schedule it:
User-added image

Thanks for any help.
 
Hello,

I have a scheduled apex class that uses the Last Modified Date in an SOQL query.  My problem is: when I create the Apex test class, I can't set the Last Modified Date to be in the past on the record that I am inserting for my test.  But when I do the insert it updates the Last Modified Date to the current date/time.  Does anyone know of a way of creating a test record where the created date and last modified date will be in the past?
Hello,

I have a scheduled apex class that uses the Last Modified Date in an SOQL query.  My problem is: when I create the Apex test class, I can't set the Last Modified Date to be in the past on the record that I am inserting for my test.  But when I do the insert it updates the Last Modified Date to the current date/time.  Does anyone know of a way of creating a test record where the created date and last modified date will be in the past?
Hi Everyone,

I'm new to Apex and I'm trying to schedule a class that I've written.  I'm going into Setup > Develop > Apex Classes and clicking on the "Schedule Apex button.  When I select my class I get an error that says "You must select an Apex class that implements the Schedulable interface."  The thing is, I thought I followed the develper documentation correctly in setting this up.  I can't figure out why it's giving me this error.  Can anyone offer some assistance?  Here's my class:
global class autoRenewalOpps Implements Schedulable {
    global void execute(SchedulableContext sc) {
    	aRopps();   
    }
    public void aRopps() {
        //Create list of renewal opportunities to close
    	List<Opportunity> renewalOpps = [SELECT StageName, Type
			FROM Opportunity
			WHERE RecordTypeId = '012S00000000klc'
			AND IsClosed = False
			AND Type = 'Renewal'
			AND CloseDate < LAST_N_WEEKS:2
			AND LastActivityDate < LAST_N_WEEKS:2
			];
        
    	//Loop through opportunities changing the type and stage
    	for (Opportunity opp : renewalOpps) {
        	opp.type = 'Auto-Renewal';
        	opp.StageName = 'Closed Won';
		}
        
        //Update the opportunities
        update renewalOpps;
    }
}
And here's the error I get when trying to schedule it:
User-added image

Thanks for any help.