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")
You cannot assign a Task to a Queue.
In your PB, if you can identify a Case that is still assigned to a Queue, then you can choose a different User altogether to whom the Task can be assigned. And this is what I understand is, you need a way to distinguish the owner type.
I have limited experience around Process Builder, but the below approach should help you to distinguish between the owner (queue vs. user) for a Case.
To identify an Owner if it's a Queue or an Owner, you can create a simple formula on your Case object and then utilize that formula in your PB to verify and take further steps accordingly. Your formula let's say is named as IsOwnerQueue
which returns a type checkbox
, the formula would be as:
Owner:Queue.DeveloperName = "<Your Queue Name>"
So if the Case is assigned to any Queue, this will always be true
. And then in your PB, you could verify if the value of the field IsOwnerQueue
is true
, then assign the Task to another User.
You could use this field elsewhere if you need to verify the owner on the Case utilizing this field.
But, as David suggested in the comments, if you only need it on a PB, then you can utilize the condition to verify if Owner Id Starts with 500
, thus signifying that the Owner is a User without the change on the Object.
Best Answer
Task and Event are often difficult objects to work with using declarative tools like Workflow and Process Builder due to their polymorphic lookup relationships. You can't traverse those relationships using dot notation
(WhatId.OwnerId)
because they can relate to almost any object.To accomplish this you need to manually traverse those relationships step by step to get to the data you want, and then update the record you want to update.
There are basically two ways that you can approach this, one is a declarative option using a combination of a Process Builder and a Flow, the other is programmatically with Apex. Below I will be detailing the declarative way to do this. For any future visitors looking for an Apex solution, the solution is to do exactly what I'm doing with these flows, but via SOQL queries and Apex variables instead.
1. Create an Auto-Launched Flow (Search for 'Flow' in setup)
2. Create 4 Flow Variables (Text)
Navigate to the Manager tab and press New Resource. Select Variable as your resource type, and Text as your Data Type. Name them as follows:
3. Get Case Info using Case Id
After creating your variables, go back to the Elements tab, and add your first Get Records element. We'll use this to query for information from the Case, mainly we want the AccountId. Configure the element as shown in my screenshots below:
Essentially what we're doing here is asking Salesforce to lookup the Case for us, based on the Case Id, and return back the Account Id and store it in the AccountId variable. This will allow us to basically do the same thing using another Get Records element which looks up the Account.
4. Get Account Info using Account Id
Repeat the exact same process as above, only this time we're using the newly collected
AccountId
variable to query for the Account, and return the OwnerId into theOwnerId
variable:5. Update the Task Record With OwnerId
Now you will add an Update Record element to the flow, which we'll be using to update the Task that started this whole process. We do that by matching the Task Id to the
ActivityId
variable, and setting the OwnerId to theOwnerId
variable:6. Save and Activate this new flow
7. Create a Process Builder that runs this Flow when conditions are met
Search for "Process Builder" in Setup, create a new Process on the Task object that runs when a record changes.
Add the appropriate criteria that you want to use to trigger the process to run (Task Type = 'Support Initiated' for example), and then add an Immediate Action with the Action Type of Flows. Name it whatever you want.
In the Flow dropdown, select the flow we just created. Then, click the + sign to add two Flow Variables, and select ActivityId and CaseId which should both be available if you set them correctly in step 2. If not, go back and check again.
Set the ActivityId to a Field Reference of [Task].Id (Called Activity Id), and set the CaseId to a Field Reference of [Task].WhatId (Called Related To Id).
8. Save and Activate the Process Builder - Test and confirm