I can't really find a solution for this, but does anyone can help me with creating Operating Hours for Apex Testing? I'm not quite sure what I have to create? Only the Operating Hours - record or more?


Apparantly it's just enough to create a record for Operating Hours.

OperatingHours oh = new OperatingHours();
oh.Name = 'TestOH';
insert oh;

You have to create a record for TimeSlot in your apex test class. Once that is inserted you will be able to test it.

  • So I have to create an 'Operating Hours'-record and a TimeSlot-record to be able to use an Operating Hours Id? We have a custom object that has a required lookup to Operating Hours. – nesnaj713 Mar 3 '19 at 14:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.