Skip to main content
Keith Hahn (Datalliance) ha fatto una domanda in #Apex
We originate cases to notify and track issues when a customer misses a deadline for sending us information.  When the case is opened for a customer serviced by our European office, we need to have the business hours on the case changed from NA (default) to EMEA.  Both business hours are set up and activated.

Cases to be serviced by the European office are identified as such from a formula field linking to the customer's configuration record (a custom object).  On the case record, this is a checkbox formula field, which gets checked if the related custom object record is checked.

I believe I need to use an Apex trigger to change the business hours, but have yet to get it working. Here's what I have so far:

trigger SetBusinessHours on Case (before insert) {

    for (Case c : Trigger.new){

    if (Europe_c)

    c.BusinessHoursId = '01m5000000004gh';

    else

    c.BusinessHoursId = '01m50000000Gs8I';

        }

Any advice to point me in the right direction would help.

 
1 risposta
  1. 1 set 2015, 11:04
    It could be due to the formula field not being calculated yet by the time the 'before trigger' is fired. Try changing it to an 'after insert' trigger.
0/9000