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
devendra dhakadevendra dhaka 

HOW TO ASSOCIATE MULIPLE OBJECTS TO A QUEUE USING APEX



i AM CREATING A QUEUE USING Group and queuesobject   . standard objects.


in the "queuesobject" there is a field 'sobjectType' where we associate supported objects to the queue.


But using apex code we are only able to attach a single object to it..



queuesobject q = new queuesobject (queueid=groupt.id, sobjecttype='test__c');   ///  this line




how can we achieve this...

AmitSahuAmitSahu

what is the issue with this you are having...??

devendra dhakadevendra dhaka

When we create a queue using setup -> administration -> manage user -> queue

 

we can associate multiple objects to the queue.

 

but using QUEUE OBJECT we can only add a single object to the queue

 

how can we achieve this ??

AmitSahuAmitSahu

Have you tried ?? 

 

queuesobject q = new queuesobject (queueid=groupt.id, sobjecttype='test__c;Lead;Case'); 

devendra dhakadevendra dhaka

No it din't work.

 

 

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Sobject Type: bad value for restricted picklist field: test__c;lead;case: [SobjectType]

 

 

'm gettin above error


AmitSahuAmitSahu

sorry you have to do like this :

 

List<queuesobject >  qus = new List<queuesobject >();


queuesobject q1 = new queuesobject (queueid=groupt.id, sobjecttype='test__c'); 

qus.add(q1);
queuesobject q2 = new queuesobject (queueid=groupt.id, sobjecttype='Lead'); 

qus.add(q2);
queuesobject q3 = new queuesobject (queueid=groupt.id, sobjecttype='Case'); 

qus.add(q3);

 

Note that the groupt.id will be same for all of them.....