You need to sign in to do that
Don't have an account?
Help with Case Owner validation Rule
Hello,
We are running a SF instance with 2 different companies under a parent company. For cases, we don't want employees of company A to be able to transfer (change ownership of) the case to an employee of company B.
I'm trying to accomplish this by entering a validation rule on the Case Owner field. Here is my initial attempt which produces a syntax error:
OwnerId.CompanyName <> $User.CompanyName
The problem I'm running into is that I don't seem to be able to access the CompanyName field for the user who is the assigned owner of the case. I'm not tied to this approach, I just need to accomplish the goal that employees of company A cannot assign cases to employees of company B and vice versa.
That is correct, because Owner is a polymorphic field -- it can be either a Queue or a User, and so the fields available to you are only the ones that make sense in both contexts (because Queues do not have a CompanyName).
I believe you may be better served by putting this logic in an Apex trigger on before insert and before update. To the end user violating it, it will look the same as if a validation rule had fired, but you'll be able to do some more complex logic as you are doing.
And by the way, how will you enforce these rules if in fact the case owner is assigned to a queue instead of a user?