Search code examples
salesforceapexsoqlsalesforce-service-cloud

Check if record has inactivity in last 4 hours


Below is my scenario :

  • Case gets created in salesforce using Email-To-Case and default owner is assigned as Queue.
  • Now if case stays with Queue and does not get assigned to any user (Meaning inactivity on that record) for 4 hours, I need to send an email to a group of user.

I have this query which gives me a record which are updated in last 4 hours. And I'm writing this logic in a class that I will be scheduling to run after 1 hours.

 List<Case> casesUpdatedInLastFourHours = [select id, Subject, LastModifiedDate from Case where LastModifiedDate = TODAY AND HOUR_IN_DAY(LastModifiedDate) > 4];

But how can we get records which are not modified in last 4 hours? Any help of suggestion is highly appreciated.


Solution

  • Just make a record trigger flow to execute after 4 hours after creation under your conditions. Then set a checkbox to true and use that as your alarm to fire your logic. Or even better yet, not do the checkbox at all and just fire the email. should be like 2 or 3 nodes altogether. no code