Hot answers tagged

22 votes
Accepted

What is the best way to check whether lead belongs to Queue or User?

The easiest way to do so is to not rely on the key prefix. Instead, just ask salesforce what the type is: if(lead.OwnerId != null) { // User is currently known if(lead.OwnerId.getSObjectType() == ...
  • 445k
14 votes
Accepted

Flow Builder - Dynamically Get Queue Id by Name

Use the GetRecords Element and Query on Groups. Add the filter to make sure Type = Queue, then add the filter for DeveloperName = (queue name).
  • 156
11 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 ...
  • 5,528
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 ...
  • 13k
9 votes

Difference between Database.executeBatch and Queueable Apex

One of the biggest differences, as you mention, is in the number that you can enqueue. Only 5 batches can be run at one time, whereas 100 Queueables can be run concurrently. Another big difference is ...
  • 144k
9 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 ...
  • 144k
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 ...
  • 4,327
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() =...
  • 445k
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 ...
6 votes
Accepted

Difference between Queues and Flex Queues

from Help & Training : "Normally, a Batch Job which has not started yet will assume the status of Queued. The batch which is currently being processed will be in the InProgress status. Batch ...
6 votes
Accepted

Queues, Email Notifications, Standard Controller Extensions. Oh My!

Congratulations. You found one of the ways that StandardController (and StandardSetController) is broken (at least, for now). I've been trying to get a straight answer about why it's as broken as it ...
  • 445k
6 votes

Query all the queue a user belong

The Sobject you should query is GroupMember. But it have the membership details of both Queue and Public Group. So you need to differentiate it using the Group type as 'Queue'. Select Group.Name from ...
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 ...
  • 445k
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: ...
  • 445k
6 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 ...
5 votes
Accepted

Queueable Execution Time Limitation

First, the "backoff" feature apparently isn't implemented yet, at least last time I tried. See this question that I asked... no response from salesforce.com or anyone else, really. That aside, the ...
  • 445k
5 votes

Difference between Database.executeBatch and Queueable Apex

The key difference can be found in the Queueable Apex documentation: Similar to future jobs, queueable jobs don’t process batches, and so the number of processed batches and the number of total ...
5 votes
Accepted

When to use queue and future method in salesforce?

You can find you answer on This link. I have pasted differences below as well - Queueable jobs provides following additional benefits - Queueable jobs are similar to future methods in that they’re ...
  • 5,210
5 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 ...
  • 5,298
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 ...
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 ...
  • 131k
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 ...
  • 445k
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 ...
  • 1,550
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 ...
  • 445k
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
  • 53.3k
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
  • 3,016
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 ...
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 ...
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 { ...
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 ...
  • 63.8k

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