You need to sign in to do that
Don't have an account?
Brendan M
get queue names from Schema, GetDescribe, Describe or alternative method
Looking to save SOQL queries in various apex classes. Just wondering if its possible to use a schema or describe method instead of an SOQL query to retrieve them?
Really appreciate any information, help or sample solution.
Code sample below where I would like to replace the SOQL if possible:
private static Map<String,ID> getQueuesByName(){ Map<String,ID> queuesByName = new Map<String,ID>(); Set<String> queueNameSet = new Set<String>{Constants.QUEUE_VEHICLES,Constants.QUEUE_GENERAL, Constants.QUEUE_CMT_RECONCILIATIONS,Constants.QUEUE_CMT_RECOVERIES, Constants.QUEUE_SFLEET_ADMIN,Constants.QUEUE_SFLEET_ACC_MGMT}; List<Group> queues = [ SELECT Id,DeveloperName FROM Group WHERE Type = 'Queue' AND DeveloperName IN :queueNameSet ]; if (!queues.isEmpty()){ for(Group queue : queues ) { queuesByName.put(queue.DeveloperName, queue.Id); } } return queuesByName; }
Yes, you can use the Schema or Describe methods to retrieve information about SObjects and fields, instead of using an SOQL query. This is known as dynamic Apex.
If you find my answer helpful, please mark it as the best answer.
All Answers
Yes, you can use the Schema or Describe methods to retrieve information about SObjects and fields, instead of using an SOQL query. This is known as dynamic Apex.
If you find my answer helpful, please mark it as the best answer.