11

I'm using the process builder to create a task and assign it to the case owner. If the case owner is a queue then creating the task fails with the following error:

FIELD_INTEGRITY_EXCEPTION: Assigned To ID: id value of incorrect type

While this scenario will likely never happen I'd like to address the possibility by determining if the owner is a user or queue and only attempt to create the task if owned by a user.

I've tried various conditions, but none of them have worked. As an example:

[Case].Owner:Queue.OwnerId Is Null = True

This criteria doesn't work because the process builder will fail if the owner actually is a user (the 99.999% use case). The failure message is:

The flow failed to access the value for myVariable_current.Owner:Queue.OwnerId because it hasn't been set or assigned.

It seems like I'm stuck. I can't access queue owner information if the owner is a user, and vice-versa I can't access user owner information if the owner is a queue.

How can I safely determine if the owner is a user or a queue?

1 Answer 1

24

Just check the first three digits of the OwnerId field (the key prefix for the Id). You can use a formula criterion here.

Is owned by User:

BEGINS([Case].OwnerId, "005") 

Is owned by Queue:

BEGINS([Case].OwnerId, "00G") 
2
  • 1
    If there are multiple conditions, will putting the BEGINS([Case].OwnerId, "005") first in an AND group prevent the rest of the conditions from being evaluated if it fails? E.g. if you have a subsequent condition that is evaluating Owner.User.Profile.Name, you do not want it evaluated at all when the owner is a queue. Aug 29, 2018 at 17:56
  • 1
    @AlwaysThinkin yes, evaluation of an AND group goes left to right, and stops when an operand of the AND evaluates to False. IDK whether this is documented as supported behavior, but I have never seen an org that did not depend on it. The same can be said of the three-letter prefixes. It's hard to understand why this necessary "typeof"/"IsA" behavior is not provided with a clear syntax.
    – ElHombre55
    Apr 30, 2021 at 19:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .