Set Entitlement Method
Wed Apr 06 2022 06:39:40 GMT+0000 (Coordinated Universal Time)
Saved by @willamaglaya
/**
* @description populates the Entitlement Id to 'Case SLA Management'
* @param cases a list of cases who status will be changed
*/
public void putEntitlementId(List<Case> cases) {
Map<String, Id> caseEntitlements = getEntitlementId();
Map<Id, String> queues = getQueues();
Map<Id, String> users = getUsers();
for (Case c : cases) {
//Set Entitlement based on Case Country
system.debug('@@@queue '+ String.valueOf(c.OwnerQueue__c));
if (c.Country__c != null) {
c.EntitlementId = caseEntitlements.get(ENTITLEMENT_NAME_Dynamic);
}
//Case Owner is assigned to NZ Queue
else if (String.valueOf(c.OwnerId).startsWith('00G') && queues.get(c.OwnerId).contains('NZ')) {
c.EntitlementId = caseEntitlements.get(ENTITLEMENT_NAME_NZ);
}
//Case Owner is assigned to NZ User
else if (String.valueOf(c.OwnerId).startsWith('005') && users.get(c.OwnerId).contains('Pacific/Auckland')) {
c.EntitlementId = caseEntitlements.get(ENTITLEMENT_NAME_NZ);
}
//Case Owner is assigned to PH Queue or User
else if ((String.valueOf(c.OwnerId).startsWith('00G') && queues.get(c.OwnerId).contains('PH'))
|| (String.valueOf(c.OwnerId).startsWith('005') && String.valueOf(c.OwnerQueue__c).contains('PH'))) {
system.debug('@@@IwentHere ');
c.Country__c = 'PH';
c.EntitlementId = caseEntitlements.get(ENTITLEMENT_NAME_PH_CorpCare);
}
//Case Owner is assigned to CorpCare MY Queue or User
else if ((String.valueOf(c.OwnerId).startsWith('00G') && queues.get(c.OwnerId).equals('CorpCare MY'))
|| (String.valueOf(c.OwnerId).startsWith('005') && String.valueOf(c.OwnerQueue__c).equals('CorpCare MY'))) {
c.Country__c = 'MY';
c.EntitlementId = caseEntitlements.get(ENTITLEMENT_NAME_MY_CorpCare);
}
//Case Owner is assigned to Finance MY Queue or User
else if ((String.valueOf(c.OwnerId).startsWith('00G') && queues.get(c.OwnerId).equals('Finance MY'))
|| (String.valueOf(c.OwnerId).startsWith('005') && String.valueOf(c.OwnerQueue__c).equals('Finance MY'))) {
c.Country__c = 'MY';
c.EntitlementId = caseEntitlements.get(ENTITLEMENT_NAME_MY_Finance);
}
//Case Owner is assigned to Australia user or queue
else {
c.EntitlementId = caseEntitlements.get(ENTITLEMENT_NAME_AU);
}
c.IsStopped = isStatusStopped(c.Status);
}
}



Comments