[SalesForce] How to perform field update before a Validation Rule? (without code)

I have a requirement in which I have to check a Cases Owner before I can insert a task. It should only allow task creation on Cases with Owners which are not queues.

At first, we tried accessing the case Owner field on a validation rule. That doesn't seem to be possible due to they way the task-case relationshop works.

Then, we tried with a field update (Process Builder, workflow rule) to update a "Case Owner Is Queue?" field on the task as it is created.
With that field updated, creating the validation rule would be simple.

The obvious problem here is that validation rules run before any process or Workflow rule.

Is there a solution to this problem? I want to avoid code unless there is no other way around it.

Best Answer

Combining a declarative field update with a validation rule is a creative idea. Some people would go right for code!

You're right about it being impossible though, since custom validation rules run before workflow rules or process builder flows could update the record. You will have to use a trigger for this.

You can run the case owner check, and then use the addError method to stop the record(s) from being saved to the database.

For reference, this is the order of execution for creating a record:

  1. Runs system validation rules and custom validation rules for multiline objects only (opportunity line-items, quote line-items, ...)
  2. Executes all before triggers
  3. Executes all Custom Validation rules, and most system validation rules.
  4. Executes all after triggers
  5. Executes assignment rules
  6. Executes auto-response rules
  7. Executes workflow rules

and so on.

Complete Order of Execution reference here.

Standard validation rules are run again after a record is updated by a workflow or process builder, but custom validation rules aren't, which leaves you stuck with a trigger.