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).
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 ...
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 ...
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 ...
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 ...
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() =...
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 ...
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 ...
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 ...
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 ...
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:
...
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
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
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 ...
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 ...
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 ...
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 ...
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 ...
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
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
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 ...
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 ...
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 = '...
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 ...
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 ...
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, ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
queue × 208apex × 46
case × 31
omnichannel × 15
trigger × 14
process-builder × 11
assignment-rules × 11
user × 10
tasks × 10
public-group × 10
soql × 8
batch × 8
visual-workflow × 8
asynchronous × 8
ownership × 8
marketing-cloud × 7
email × 7
unit-test × 6
workflow × 6
liveagent × 6
future × 6
servicecloud × 6
callout × 5
error × 5
list-view × 5