Skip to main content
Planned maintenance impacting Stack Overflow and all Stack Exchange sites is scheduled for Monday, September 16, 2024, 5:00 PM-10:00 PM EDT (Monday, September 16, 21:00 UTC- Tuesday, September 17, 2:00 UTC). The email/password authentication method will be unavailable for logging in and registering. Read more here
16 votes
Accepted

Flow Builder - Dynamically Get Queue Id by Name

Use the GetRecords Element and Query on the Group object. Add the filter to make sure Type = Queue, then add the filter for DeveloperName = (queue name).
Kristina Dillon's user avatar
15 votes

Error "Too many queueable jobs added to the queue: 2"

Salesforce says you can add 50 jobs to the queue per transaction. But what Salesforce doesn't mention clearly is that it is not applicable for batch, you can only enqueue one job. Even if you enqueue ...
brovasi's user avatar
  • 5,685
13 votes
Accepted

Error "Too many queueable jobs added to the queue: 2"

You have two things going on here: You can only execute one job from a job. Triggers fire in chunks of 200 records. So if you update 201 records, you will have one Queueable kicked off with 200 ...
Adrian Larson's user avatar
  • 151k
11 votes
Accepted

Guarantee only a single asynchronous job runs at a time

I've implemented the following in numerous orgs and it works pretty well. It's similar to Keith's suggestion, but a bit more detailed and it does usually do near-realtime processing: Create a custom ...
Aidan's user avatar
  • 13.9k
8 votes

Reduce the risk of my Queueables to harm other async jobs

This is just a thought, but say you have Accounts, Contacts, Leads(whatever your objects are) and everytime one of these records qualify for changes (whatever that may be) you can create a new record ...
EricSSH's user avatar
  • 4,344
8 votes
Accepted

How to determine if case owner is queue with specific developer name

There's no direct relationship between Owner and DeveloperName, because it is a Name object. If you really want to check by developer name, you'll have to query for it: if(c.ownerid.getsobjecttype() =...
sfdcfox's user avatar
  • 500k
7 votes
Accepted

Query queues belonging to a particular sobject

There is a QueueSobject from which you will get the queues along with the object assigned to it. Please check the below query: SELECT QueueId, Queue.Name, SobjectType FROM QueueSobject WHERE ...
pranaya bhoyar's user avatar
7 votes

How can I use queue data structure in Apex?

There is no inbuilt functionality for that. You need to write the custom class for that. public class Queue { private List<Object> fifoList = new List<Object>(); public ...
Rahul Gawale's user avatar
  • 12.2k
6 votes
Accepted

How to convert a lead owned by queue?

When converting leads owned by a queue, the owner must be specified. This is because accounts and contacts cannot be owned by a queue. Even if you are specifying an existing account or contact, you ...
smukov's user avatar
  • 5,613
6 votes
Accepted

Bulk Data Load jobs very slow; what's holding up the queue?

The Bulk API operates like other asynchronous features, such as the Metadata API, Batchable classes, Sandbox refreshes, and so on. It goes in to a queue and is processed as resources allow. If you ...
sfdcfox's user avatar
  • 500k
6 votes
Accepted

Is it normal to tests not be able to create queues because there's one with the same name on the organization?

Setup Objects, like Queues and Users, can be queried without SeeAllData in unit tests. There's no need to explicitly create these objects under normal circumstances. The documentation says: ...
sfdcfox's user avatar
  • 500k
5 votes

Why would an Email sent from a journey get stuck in the triggered send queue with no error?

So as I posted this question, an email came through from Salesforce support thanks to auto case opening we have when any of our triggered sends are paused due to an error and the error gave me the ...
JulieHurtz's user avatar
5 votes
Accepted

Unable to fetch queues in Live agent button + omni channel

Queue->select the queue which u r using in omni ->Supported Objects-> select Live Agent session and Transcripts. Then it will works
phani's user avatar
  • 66
5 votes

Guarantee only a single asynchronous job runs at a time

The only locking mechanism I know of is the SOQL for update. (But appears broken at the moment for this scenario - see Webservice Callouts within a Select For Update statement are not blocked per ...
Keith C's user avatar
  • 137k
5 votes

Queues for Custom Objects

1) Queue for a Custom Object is already created and added with few internal users. Now, when the records of the custom object is assigned to the Queue, how the members of the queue pick up the record ...
sfdcfox's user avatar
  • 500k
5 votes

Query queues belonging to a particular sobject

You can use QueueSobject for this. QueueSobject represents the mapping between a queue Group and the sObject types associated with the queue, including custom objects. Sample query: QueueSobject ...
Pragati Jain's user avatar
  • 1,580
4 votes

Queueable Execution Time Limitation

Followup to @sfdcfox answer At least as of V40.0 when I started testing this, the Queueable backoff is definitely implemented. I ran a small test where I created an initial queueable that then chained ...
cropredy's user avatar
  • 72.6k
4 votes
Accepted

Queue email not being sent for custom object created via a public site

Yes, the default is not to send an email. If you're using a DML statement in your page, you can set the DmlOptions emailHeader. It looks approximately like this: Database.DmlOptions option = new ...
sfdcfox's user avatar
  • 500k
4 votes
Accepted

Trigger Process Builder when user receives lead, not queue

In your Process Builder criteria diamond check the Lead OwnerId starts with 005 This will tell you whenever a Lead is assigned to a User instead of a Queue
dBeltowski's user avatar
  • 3,048
4 votes
Accepted

DeDupe Trigger on Lead not working

Your list is of the email address and your query is checking for and id in that list. Id's do not equal email addresses so no contacts are returned It should be where email in :leadEmails
Eric's user avatar
  • 54.3k
4 votes

salesforce find number of users in all queues

Try this: SELECT COUNT(UserOrGroupId), Group.Name FROM GroupMember WHERE GroupId IN (SELECT QueueId FROM QueueSobject) GROUP BY GroupId,Group.Name Verified this in my org and ...
javanoob's user avatar
  • 8,917
4 votes

Time Dependent Workflow with multiple email alerts

I think this work this way because of the queue system, it run all the "outdated" action to be executed in the next hour it is inserted, if you see the considerations for this kind of process, it ...
sebmaldo's user avatar
4 votes

Too many queueable jobs added to the queue: 2

See: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm Executes all after triggers ... ... Executes workflow rules. If there ...
Denis Osmakov's user avatar
4 votes
Accepted

Solution on Calling queueable from Batch causing exception of "System.LimitException: Too many queueable jobs added to the queue: 2"

Assuming you can't refactor to allow things to happen for you, how about using this pattern: public interface Action { void execute(); } public class CalloutPlusDMLAction implements Action { ...
Phil Hawthorn's user avatar
4 votes

Error "Too many queueable jobs added to the queue: 2"

Here's another use case one might encounter when getting this error Given: Batch job execute() method that updates two records A and B Given a Process Builder with two decision blocks / action group ...
cropredy's user avatar
  • 72.6k
4 votes
Accepted

Need to change OwnerId field to Queue's Id if the creator of the record isn't from this Queue

You want to use groupQueue.Id instead of set recordIds public static void helper(List<Object__c> newList) { Group groupQueue = [ select Id from Group where Name = '...
Oleksandr Berehovskyi's user avatar
4 votes
Accepted

It can't see my Queue: "Expected: 0, Actual: 1"

You haven't inserted any records in to the queue yet, so 0 is the expected value. Instead, you need to follow the following steps: insert the Group, insert a QueueSObject, then insert at least one ...
sfdcfox's user avatar
  • 500k
4 votes
Accepted

How to find Queue Priority number?

Apparently, you have to do this in two queries. First, get the QueueRoutingConfigId field: Group[] groups = [select QueueRoutingConfigId from Group where Type='Queue']; Set<Id> routingConfigIds ...
sfdcfox's user avatar
  • 500k
4 votes

Get ALL queue Users

I think you can combine a couple answers to questions and be able to get something working well. You listed all the requirements in all the ways someone can be added to a queue. If we simplify it, ...
Kris Goncalves's user avatar
4 votes
Accepted

Why does adding a Queueable cause an INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY error?

It is because you need to send the NetworkId. Network.getNetworkId returns null during queuable invocation. So, it is necessary to pass around or query the NetworkId as soon as you introduce async ...
Jeferson Chaves's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible