How do I query queue ID in Apex?

  • How do I query queue ID in Apex?

    Known parameters:

    1. Queue Name
    2. Supported object

    Miscellaneous information:
    The reason I need queue ID in Apex because my routing logic assigns selected records to a queue on the click of a commandButton. Currently I have hard-coded the queue ID for testing.

    record.OwnerId = '00GQ0000001nx6v';
  • jkraybill

    jkraybill Correct answer

    8 years ago

    Queues are stored as a Group SObject, so

    select Id from Group where Name = 'My Group' and Type = 'Queue'

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM