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
fredkafredka 

Assign Queue as Case Owner using Trigger

Hi.  I am trying to assign a queue as the case owner.. In a Case Before Trigger, I am have the following.  The case owner is getting updated if the abm__c field is populated.. however, it does not get updated with the queue if that field is null.

Account_Team__c at = aMap.get(c.AccountId);
                // Only change the owner if the Account Team has
                // an ABM and the ABM is an active user. Once assigned
                // set the flag Assigned to ABM
            if (string.isNotBlank(at.abm__c)) {
                if (at.abm__r.IsActive) {
                    c.ownerid = at.abm__c;
                    c.Assigned_To_ABM__c = true;                    
                }
             }
              else {
                c.ownerid = abmQueue[0].Id;
                }

Any help woudl be greatly appreciated!!

Fred
Best Answer chosen by fredka
_Zach Boyd_Zach Boyd
I have not used the QueueSObject class before, however I see that it has a QueueId field. Try using that and the owner should be assigned properly.

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_queuesobject.htm

 

All Answers

fredkafredka
Sorry, here is the list:   List<QueueSobject> abmQueue = [SELECT Id FROM QueueSobject WHERE SobjectType = 'Case'and queue.Name = 'ABM Cases' LIMIT 1];
_Zach Boyd_Zach Boyd
I have not used the QueueSObject class before, however I see that it has a QueueId field. Try using that and the owner should be assigned properly.

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_queuesobject.htm

 
This was selected as the best answer
fredkafredka
Thanks Zach!!