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
RyanLorenzenRyanLorenzen 

Help with Case Trigger to populate case owner's manager

We're changing from populating Case Owner's Manager Email to populating the Manager in a lookup.   I'm looking for assistance on what I need to change in this trigger.  I have created a new field called "Case_Owner_Manager__c"


        //Prepare a map b/w case's owner Id and their names
        if(caseOwnerIds.size() > 0) {
            for(User caseOwner : [Select Id, Name, ManagerId, Manager.Email From User Where Id IN :caseOwnerIds]) {
                if(caseOwner.ManagerId != null) {
                    mapOwnerIdAndName.put(caseOwner.Id, caseOwner.ManagerId);
                }
            }
        }

        for(Case newCase : casesToPopulateManager) {
            if(mapOwnerIdAndName.containsKey(newCase.OwnerId)) {
                newCase.Case_Owner_Manager__c = mapOwnerIdAndName.get(newCase.OwnerId);
            }
        }
    }
SivaGSivaG
Hi Ryan,

While populating the list casesToPopulateManager did you include Case OwnerID as well in the query? If not you have to modify your code to populate it. Could you please post the full code.

Thanks
Kumar

 
RyanLorenzenRyanLorenzen
Thanks for replying, I was able to figure it out.  : )
Tamal chakrabortiTamal chakraborti
hi Ryan can you post me the working code we have a similar requirement to transfer case/assign case older tahn 30 days and not closed to re assign to urrent owners  manager!!!