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
IKZIKZ 

field updated by class only when record is edited, how to change to dynamic live update?

we update Business_Hours_SLA_Start_Initial_Now__c with number of business hours (between CreatedDate & now) and it works fine, but I would like to change that to live update rather than number of hours between created and last modified as it's doing now
 
if (newCase.CreatedDate != null && newCase.BusinessHoursId != null) {
            Double timeSinceLastStatus = BusinessHours.diff(newCase.BusinessHoursId, newCase.CreatedDate, Datetime.now())/3600000.0;
            newCase.Business_Hours_SLA_Start_Initial_Now__c = timeSinceLastStatus;
            System.debug(newCase.Business_Hours_SLA_Start_Initial_Now__c);
        }
thank you in advance