Skip to main content
Anil Rao (NBC Universal) 님이 #Apex에 질문했습니다
I have 2 Queues - AsiaQ & EuropeQ. I have a Apex API that converts a Cart Custom Object record into a Lead record. The Lead record has a field callled Region which takes Asia or Europe. Based on the region selected, I want the Lead to be assigned to either AsiaQ or EuropeQ.

 

Below code works: I have hard coded the Q IDs.

ID QID;

Lead indLead = new Lead();

if (indLead.region__c == 'Asia')

      QID = '00G46000000nsXy';

else

    QID = '00G46000000nsY3';

indLead.ownerid = QID;

I dont want to hard code. I want to get the Q ID based on the region in the Lead record.

Below is the code. This is NOT working. Pl. help & suggest what mistake I am doing -

ID QID;

Lead indLead = new Lead();

QID = [select queue.id from QueuesObject where Queue.Name = :indLead.region__c limit 1];

indLead.ownerid = QID;

I have confirmed that :indLead.region__c has the correct value of Asia or Europe.
답변 3개
  1. 2018년 11월 28일 오전 6:24
    Hi,

    You can try below query to get queue Id 

     

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

    Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.

                                                 

    Best Regards

    Sandhya