function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ram_devram_dev 

need to assigned case to perticuler queue.

Hi,

 

I've trigger for generating case whenever some fields are updated on perticuler object. The generated case must be assigned to perticuler queue(queue1).  i wrote soql query for this. its got worked perfectly when that case contains only one queue. now we have multiple queues(queue2, queue3..etc). now it is not working. what changes i need to do in my trigger code. the below is the query i used earlier:

list<QueueSobject> q = [select Id, QueueId from QueueSobject WHERE SobjectType = 'Case'];

 

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

How about adding some extra filters to your SOQL ?

Something like Queue Name?

 

list<QueueSobject> q = [select Id, QueueId from QueueSobject WHERE SobjectType = 'Case' AND Queue.Name ='MY CASE QUEUE'];

 

Check the above SOQL it has a added filter for QUEUE name.

All Answers

Avidev9Avidev9

How about adding some extra filters to your SOQL ?

Something like Queue Name?

 

list<QueueSobject> q = [select Id, QueueId from QueueSobject WHERE SobjectType = 'Case' AND Queue.Name ='MY CASE QUEUE'];

 

Check the above SOQL it has a added filter for QUEUE name.

This was selected as the best answer
ram_devram_dev

Hi,

 

Thankyou. I already applied this. AM getting error list index out of bounds. Am assigning it like,

vCase.q= vlstQ[0].QueueId;

what i need to change. can you suggest me

 

 

Avidev9Avidev9

This means there are no matching queues to that criteria that you added. You have check whether the query returned records before using the value by doing 

if(!vlstQ.isEmpty()){
       vCase.q= vlstQ[0].QueueId;
}

 

ram_devram_dev

Hi,

 

Thankyou very much for your quick reply. Case generated but case owner is coming like my name. not the Queue name. wt do?

(queue contains Different users. so we need to get the queue name there like  my case generation).

Avidev9Avidev9

As I said "This means there are no matching queues".

 

Try runing the query in developer console and check if any result is returned. I am pretty much sure its not returning any value. 

 

Please make adjustment accordingly to the SOQL so that it returns the desired QUEUE.

ram_devram_dev

hi,

Thankyou very much for your help

 

you are correct. I tried below soql query in developer console . it is getting the error like "Unknown parcing error."

Below is the my query:

list<QueueSobject> q = [select Id, QueueId from QueueSobject WHERE SobjectType = 'Case' AND Queue.Name = 'queue1'];

 

queue1 is ther in queues. but why  it is not considering. 

 

Avidev9Avidev9

man the query editor just takes the query. That is

select Id, QueueId from QueueSobject WHERE SobjectType = 'Case' AND Queue.Name = 'queue1'

 

Please double check if the queue is supported for Case, and please double check the Queue Name.

 

 

ram_devram_dev

Thankyou. Its worked..