1

I have a class that is looking for contracts 30 days before the end Date.

My problem is i am trying to build a test for this class, and in that i'm trying to create a contract where the End Date is 30 days ahead of today's date. No matter what i set the contract Term as, the endDate is always getting set as a year from today, rather than from the contract StartDate and the Term.

Does anyone have any suggestions here?

    contract con = new contract();

    con.StartDate =system.today().addMonths(-11);
    con.ContractTerm=12;
    insert con;
    con.Status = 'Activated';
    update con;
    system.debug(con.StartDate+'<-----------Start  End----------->'+ con.EndDate);

Debug line: 14:22:41:910 USER_DEBUG [64]|DEBUG|2017-12-13 00:00:00<-----------Start End----------->2019-11-12 00:00:00

  • Have you checked if you have any process builder / workflow / 3rd party apps that may be setting the End Date? – David Cheng Nov 15 '18 at 5:54
  • @DavidCheng - I found a contract setting "Auto-calculate Contract End Date". I switched this off an i was able to set the End Date manually for my test – denisoleary Nov 16 '18 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.