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
Sujit KSujit K 

Send an email after 4 hours of Inactivity on Cases

Hi All,

I have a requirement wherein we need to send an email to a group of users if cases is not assigned within 4 hours after it gets created.
  • The case is getting created in salesforce using Email-To-Case and assigned to Queue as default case owner.
I've written a SOQL query which gives case records that are updated in last 4 hours but not sure how we can get cases which are not updated or not have actioned in 4 hours after cases's created time.
 
List<Case> casesUpdatedInLastFourHours = [select id, Subject, LastModifiedDate from Case where LastModifiedDate = TODAY AND HOUR_IN_DAY(LastModifiedDate) > 4];

Any help or sugegstion is highly appreiciated.
AnkaiahAnkaiah (Salesforce Developers) 
Hi Sujit,

Create a formula field to caculate the hours based on case created date and now() you will get the time diffrence if the case owner is still queue.

Formula should be like below.
If(Owner:Queue.DeveloperName ="High_Priority_Cases",
(Now()-CreatedDate)*24,0)
Note: above formula calulates the time differenece current time & createddate untill the case owner as queue.

Refer the datetime formula help article.
https://help.salesforce.com/s/articleView?id=000324878&type=1

\Create a workflow rule using below conditions:

Evaluation Criteria:
3rd option: created, and any time it's edited to subsequently meet criteria
Rule Criteria: 
formula_field __c > 4
Email alert:
send an email alert to the respective users.

If this helps, Please mark it as best answer.


Thanks!!
Sujit KSujit K
Hi Ankaiah,

Workflow rule will fire when there is Insert or Update on a record. But here we need to know if the record is not edited in 4 hours after it is created.

Any workaround for this?
AnkaiahAnkaiah (Salesforce Developers) 
Hi Sujit,

That is what the formula will do. If the record owner not changed untill 4 then workflow criteria will met and send the notifications to the respective user.

Try that, it will work.

Thanks!!
Sujit KSujit K
Hi Ankaiah,

The workflow rule will not trigger on formula field changes as per the documentation here

https://ideas.salesforce.com/s/idea/a0B8W00000GdW63UAF/allow-changes-in-formula-field-value-to-trigger-workflow

Correct me If I am wrong

Thanks,
Sujit