How to Dynamically Get Queues in Salesforce Flow

How to Dynamically Get Queues in Salesforce Flow

Queues in Salesforce help make it easier to manage shared workload. Instead of a specific person owning a record, the queue owns it until someone is ready to work on it. Sometimes, you might need to find queues related to a specific object in Salesforce Flow. For example, you may want to show these queues as choices in a Screen Flow. While you could hardcode these choices, it’s better to dynamically retrieve queues for a specific object type. Here's how you can do it.

Queues in the Database

Queues are stored in the Group object. This object holds various types of user groups, including roles, public groups, queues, and more. You can use the Type field to identify the queues in the system.

For example, the query below retrieves the queues in your Salesforce environment.

SELECT Id, Name FROM Group WHERE Type='Queue'

Although it might seem like the Group object is what you need to retrieve in Flow, it’s missing one important detail. The Group object doesn’t store the related object information. This means you can’t simply use Group records to find queues linked to a specific object.

Another object links queues to their related objects, which makes sense since a single queue can be connected to multiple objects. The Queue sObject object is what you need. It has only two fields: QueueId and SobjectType.

How to Get the Queues Related to a Specific Object

As mentioned earlier, you first need to retrieve the Queue sObject records and then the related Queues. For example, let’s find the queues related to the Case object.

1- Add a Get Records element to get the Queue sObject records.

Get Queue sObject Records

2- Add a Transform element to create a text collection of Queue IDs.

Transform to Queue IDs

3- Add another Get Records element to get the queues.

Get Queues in Salesforce Flow

At the end of this step, you will have the queues related to the Case object. You can then use a collection choice set to display them as options.

For example, here’s a Screen Flow that allows the user to select an object. It then uses the reactive Screen Actions feature to dynamically retrieve the related queues.

Get Queues

Be the first to comment

Leave a Reply

Your email address will not be published.


*