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
Kunal01Kunal01 

BusinessHour Record in Test method.

Hi,


I am facing one issue with creation of Business hour test data in one of my test method. while inserting businesshour test record it is giving an exception "Save error: DML not allowed on BusinessHours".

If I can't create BusinesssHour record in test method than how do i refer to the busnesshours record for the test coverage.

Thanks,
Kunal.

bob_buzzardbob_buzzard

While you can't create business hours on the fly, you will have a default set of hours in place at all times, so I use that.  It does make the tests slightly artificial in that you can't test the actual advancement of business time without simply executing the addition in your test method.