+ Start a Discussion

How to set two sbjects to a queue by apex?

When I create a queue on browser, it's possible to configure two sbjects or more in a queue, but i can't to do the same thing in apex class.
How can I accomplished this?

For instance:

QueueSobject qs = new QueueSobject(SobjectType='MyObject1__c;MyObject2__c', Name='My queue test');
Database.insert( qs );

This is what i want or something like that.

Best Answer chosen by c_r_carvalho
You just need to insert two of them
Queue myQueue = [
     select Id
     from Group
     where Name = 'My queue test' and
          Type = 'Queue'

List<QueueSobject> qs = new List<QueueSobject>();
qs.add(new QueueSobject (
     QueueId = myQueue.Id
qs.add(new QueueSobject (
     QueueId = myQueue.Id
Database.insert( qs );