function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RelaxItsJustCodeRelaxItsJustCode 

Need help with Apex Service class? I will give kudos to anyone that contributes.

I've never built a Apex Service....  Below is a description of what I'm trying to do.  I will give kudos to anyone that contributes.

 

Do you have any info on Apex Services?

 

 

What I need is a way to look at the contracts and create a new contract 60 days before the previous contracts end date.

 

I have the code that will build the follow up contract, what I don't have is a way minus using Time Based Workflow to query all contracts that are in the window of renewal of Maint or expiration and create new contracts for those that are 60 days out from expiration.

 

Any ideas?

 

Thank you,

Steve Laycock

Best Answer chosen by Admin (Salesforce Developers) 
Sandeep001Sandeep001

Hello Steve, 

 

I am not sure if I have got the requirement right but here is what I think you can do:

 

You can schedule an apex class to run everyday and query (SOQL) the Contract records whose expiry date =  System.TODAY() + 60

 

For all the records retrieved, you can create a new contract for them.

 

Please go through the below link to schedule a class:

 

www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

 

All Answers

Sandeep001Sandeep001

Hello Steve, 

 

I am not sure if I have got the requirement right but here is what I think you can do:

 

You can schedule an apex class to run everyday and query (SOQL) the Contract records whose expiry date =  System.TODAY() + 60

 

For all the records retrieved, you can create a new contract for them.

 

Please go through the below link to schedule a class:

 

www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

 

This was selected as the best answer
RelaxItsJustCodeRelaxItsJustCode

Thank you very much Sandeep.

 

Steve Laycock