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
emilyftwemilyftw 

BusinessHours - using addGMT

I am getting an error when getting the default BusinessHours and adding 1000 milliseconds. Here is the code I am running in the system log:

 

 

BusinessHours bh = [select id from businesshours where isDefault = true];
DateTime dt = System.now();
DateTime test = BusinessHours.addGmt(bh.id, dt, 1000);

 

 

And this is what the log shows:

 

 

13:58:42.297|METHOD_ENTRY|[3]|BusinessHours.add(String, Datetime, Long)
13:58:42.298|METHOD_EXIT|[3]|BusinessHours.add(String, Datetime, Long)
13:58:42.298|FATAL_ERROR|Internal Salesforce.com Error

 

Am I doing something wrong?

 

Best Answer chosen by Admin (Salesforce Developers) 
emilyftwemilyftw

In case anyone else is struggling with this, I found that I needed to create a variable for the interval instead of passing it in directly. Here is the revised code that is functional:

 

 

BusinessHours bh = [select id from businesshours where isDefault = true];
DateTime dt = System.now();
Long interval = 1000;
DateTime test = BusinessHours.addGmt(bh.id, dt, interval);