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
Giancarlo AmatiGiancarlo Amati 

BusinessHoursUtilities.BusinessHoursHelper bhHelper returned null

Dear Team,
we've found the following code of a Case Trigger which emits an error message related to the case owner time zone. I checked the users' time zone both in the SFDC Admin --> Users and also in every single profile in the "My Settings" section. They all have a timezone assigned but for some reason, I believe the bcHelper variable is always NULL and so it triggers the error message.
Where else should I be looking at?

Thank you. 

GC
 

Cannot match case owner's time-zone to
a business hour/holiday record; please update case owner's time-zone in the user profile
 
BusinessHoursUtilities.BusinessHoursHelper bhHelper =
mapBusinessHoursHelpersByUserId.get(c.OwnerId);
if (bhHelper == null) {
c.addError('Cannot match case owner\'s time-zone to
a business hour/holiday record; please update case owner\'s time-zone in
the user profile.');
}

 
Giancarlo AmatiGiancarlo Amati
Hi Team, 
this is what a grabbed from the long:
1. for a user with time zone set in IST (India) I get:
16:42:47.789 (922396936)|VARIABLE_SCOPE_BEGIN|[106]|caseContact|Contact|true|false
16:42:47.789 (922427433)|VARIABLE_ASSIGNMENT|[106]|caseContact|{"Id":"0031400002IbivGAAR","Email":"gamati@brightcove.co (1 more) ..."}|0x764b5990
16:42:47.789 (922434329)|STATEMENT_EXECUTE|[110]
16:42:47.789 (922449350)|STATEMENT_EXECUTE|[113]
16:42:47.789 (922485801)|VARIABLE_SCOPE_BEGIN|[113]|bhHelper|BusinessHoursUtilities.BusinessHoursHelper|true|false
16:42:47.789 (922496525)|VARIABLE_ASSIGNMENT|[113]|bhHelper|null|

For a case owner based in GMT or EST I get the following:
 
17:00:30.704 (3007120748)|VARIABLE_SCOPE_BEGIN|[106]|caseContact|Contact|true|false
17:00:30.704 (3007157795)|VARIABLE_ASSIGNMENT|[106]|caseContact|{"Id":"0031400002IbivGAAR","Email":"gamati@brightcove.co (1 more) ..."}|0x60e8988f
17:00:30.704 (3007168569)|STATEMENT_EXECUTE|[110]
17:00:30.704 (3007171012)|STATEMENT_EXECUTE|[113]
17:00:30.704 (3007199332)|VARIABLE_SCOPE_BEGIN|[113]|bhHelper|BusinessHoursUtilities.BusinessHoursHelper|true|false
17:00:30.704 (3007244673)|VARIABLE_ASSIGNMENT|[113]|bhHelper|{"bh":"0x6cb38a5e"}|0x1d5356a5

I don't think it's a matter of coding but why the BusinessHoursUtilities is behaving like this. It looks that to the first Case OwnerID doesn't have business hours or Time zone linked. 
Thank you.
GC