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?


2 Answers 2


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, 2019 at 14:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .