+ Start a Discussion
Flora FuFlora Fu 

How to prevent assigning cases to users who has set 'out of office' in Calendar Event?

Hi Team,
We are trying to use the SF Calendar for users to log their availabilities. And if the user creates a calendar event as 'Out of Office' during a period, we want to set up a validation rule to prevent any cases assign to that user during that period.  However, when setting up the validation rule i cannot find the 'show time as' field. Could you advise how this can work?

Or would be appreciated if any one can suggest other ways we can use to manage that cases will not assign to users who are out of office, and which can be turnned on/ off by set a date/time range.
I do not think you can do this via a validation rule.  You could do this via a trigger that does the following:
  1. Before insert build a set of all OwnerIds
  2. Query all Calendar events for those OwnerIds that meet your criteria for Out of Office
  3. Take all of the calendar events and build another set of OwnerIds that are Out of Office
  4. Iterate over all of the new cases and if the OwnerId field is in the out of office set, do something
    • You could do a couple of things here:
      • Query all Users that are Out of office for a custom look up field that is "backup" that points to a user and then use that to re-assign
      • Do an addError to the record to reject it being saved.