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
ketan mehtaketan mehta 

Issue with assigning opportunity to a queue.

Hi, 
   I am trying to assign an opportunity to a queue as below in a trigger. 
 
list<QueueSobject> queueId = [Select q.SobjectType, q.Id From QueueSobject q where q.Queue.Name =:'test-Queue'];
opp.OwnerId = queueId[0].Id; 

I am getting an exception as below: 
id value of incorrect type: 00G90000001gfFoEAI

Generally i can see all the other ids with length of 15 but the id in  exeption is 18 characters...????

Please guide. 
Best Answer chosen by ketan mehta
ketan mehtaketan mehta
Hi All,
     Now I am able to assign the object to queue. I have just change the query as below in my trigger. It is still retriving the Id with 18 character but working fine.

trigger OnUpsertTestCustomObject on TestCustomObject__c (before insert, before update) {

    //Get queue id
    list<QueueSobject> queueList = [Select QueueId From QueueSobject q where q.Queue.Name =:'test_queue'];
   
    for(TestCustomObject__c obj : Trigger.new)
    {
      obj.OwnerId = queueList.get(0).QueueId;
    }
}

Thanks a lot for ur help :)

All Answers

kiranmutturukiranmutturu
I doubted that we can't assign a queue to opportunity... Reference https://help.salesforce.com/HTViewHelpDoc?id=queues_overview.htm&language=en_US (https://help.salesforce.com/HTViewHelpDoc?id=queues_overview.htm&language=en_US)
logontokartiklogontokartik
I am not sure if you are using right object to get the QueueId, it should be Group object that you need to query, 

List<Group> queues = [Select Id, Name from Group where Type = 'Queue' And Name = 'test-Queue'];
opp.OwnerId = queues[0].Id

Even if you query QueueSObject, you need to use "QueueId"  field to get the right Id. not "ID" field.

Hope this helps.
Ravi NarayananRavi Narayanan
i suppose Queue is only for Leads and Cases 
ketan mehtaketan mehta
Hi Kartik,
    I tried with ur solution but still the same error. I am getting an id as 00G90000001gfFoEAI Still the id is with 18 character.


Ravi,
   Admin has rights to configure any object for Queue.
Ravi NarayananRavi Narayanan
User-added image

No.. you cannot assign a Queue as owner of Opportunity. It is only for leads and cases.. Correct me if i am wroong 
logontokartiklogontokartik
Ok sorry I havent seen which object you are trying to assign queue to, Yeah Ravi is right, you cannot have queues assigned to opportunity as owner. Thats a limitation. Please do a search for Opportunity Queue on web and you can get many workarounds. Thank you. 
ketan mehtaketan mehta
Hi Ravi,
     From my custom queue I can set my custom object for the queue. But while on create a custom object and assigning to the queue I am getting an I 18 character Id which throws an error. Refer the screenshot.


 QueueConfigurationCustomObjectCreateTrigger

Please guide.

Ravi NarayananRavi Narayanan
can u hardcode the id value n ur trigger and check ? 
Ravi NarayananRavi Narayanan

otherwise try to remove last 3 char from ur string. 

 

obj.ownerid=queuelist.get(0).id.substring(0,15);

kiranmutturukiranmutturu
is that custom object is on detail side of the master detail relationship? If yes then you cant assign a queue to that custom object... 
ketan mehtaketan mehta
No, this is just a custom object and does not have any relation with any other object
ketan mehtaketan mehta
Ravi, I tried to do the same but the same issue. I don't know after assigning the same way it is attaching  AAC  at the end of the id... it's very strange for me. 
ketan mehtaketan mehta
From the UI, I am able to set the record to queue. FYI
ketan mehtaketan mehta
Hi All,
     Now I am able to assign the object to queue. I have just change the query as below in my trigger. It is still retriving the Id with 18 character but working fine.

trigger OnUpsertTestCustomObject on TestCustomObject__c (before insert, before update) {

    //Get queue id
    list<QueueSobject> queueList = [Select QueueId From QueueSobject q where q.Queue.Name =:'test_queue'];
   
    for(TestCustomObject__c obj : Trigger.new)
    {
      obj.OwnerId = queueList.get(0).QueueId;
    }
}

Thanks a lot for ur help :)
This was selected as the best answer
Ravi NarayananRavi Narayanan
have u tried the way i suggested.. it will remove 3 char from the string/id and make it 15 char id.