1

I have been asked to fill a custom field named "Group" with the Case's Owner Queue Name. I have created a formula field like this

CASE(
        Owner:Queue.Id, 
        '00Gw0000002RvtS', "Gruppo A - Operations", 
        '00GZ0000001ls0m', "Gruppo B1 - TP_Service",
        "00Gw0000002RvtU", "Gruppo B2 - Infogroup",
        "00Gw0000002RvtW", "Gruppo C - Crediti",
        "00Gw0000002RvtX", "Gruppo D - Fatturazione",
        "00Gw0000002RvtY", "Gruppo E - Commerciale",
        "00Gw0000002RvtZ", "Gruppo F - Prospect",
        "00Gw0000002Rvta", "Gruppo G - TOP",
        "00Gw0000002Rvtb", "Gruppo H - PA",
        "00GZ0000001ltX8", "Gruppo I - Recard",
        "No_Value"
)

Now if the case owner is a queue then the result is ok, but if the owner is a User the formula doesn't work. Is there any way to address this? I have tried to create a trigger, but I'm not a coding expert so I didn't succeed. Any help?

Thanks in advance Axl

3

You can just use the Queue name, that's available to you in the formula. Something like this should work

IF(
     Owner:Queue.Id <> null,
     Owner:Queue.QueueName,
     "No Value"
)
1
trigger createNewCase on Opportunity (before insert , before update) 
{
   //Create a map with UserId to respective values

   map<Id, String> mapUserIdToSTring = new map<Id, String>{'UserId1' => 'Gruppo A - Operations',
                                                            'UserId2' => 'Gruppo B1 - TP_Service',
                                                            'UserId3' => 'Gruppo B2 - Infogroup'
                                                            'UserId4' => 'Gruppo C - Crediti'};
    for(Opportunity objOpp:Trigger.New)
    {
      if(mapUserIdToSTring.containskey(objOpp.OwnerId))
      {
         system.debug(mapUserIdToSTring.get(objOpp.OwnerId)); //you will get Group Name based on User Id. Perform your logic here
      }
    }
}

Create trigger and add the values into map. In above example UserId1, UserId2 replace with actual User record id. Also remove the single quote.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.