• KennyShen
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

Hi,

 

I'm working on a trigger to call a class which assigns an Entitlement on Cases according to the Priority and Account on the case. The trigger and class both work for cases created internally, but won't work for customers through the customer portal. Below are the triggers and class involved. The customer portal profiles have Read access for the Entitlement object. Any help would be greatly appreciated!

 

trigger AssignEntitlementTrigger on Case (before insert){

    Case[] cases = trigger.new;
    List<Id> CaseAccounts = new List<Id>();
    List<Entitlement> EntitlementToAdd = new List <Entitlement>();
    Case cA = cases[0];
      if(cases[0].Priority == 'Critical'){
            EntitlementToAdd = [Select Id From Entitlement 
                                    Where AccountId = :cA.AccountId and 
                                    Entitlement.Support_process__c = 'Critical' 
                  limit 1];
//                trigger.new[0].Action_needed_by__c = 'BigMachines';
        }
      else if(cases[0].Priority != 'Critical'){            
            if(cases[0].Support_Product__c == 'Premium'){
                   
              EntitlementToAdd = [Select Id From Entitlement 
                                    Where AccountId = :cA.AccountId and Entitlement.Support_Process__c = 'Premier'
                                    limit 1];
//                   trigger.new[0].Action_needed_by__c = 'Customer';
            }
        else {               
            EntitlementToAdd = [Select Id From Entitlement
                                Where AccountId = :cA.AccountId and Entitlement.Support_Process__c = 'Standard'
                                limit 1];
//         trigger.new[0].Action_needed_by__c = 'User';
        }
       }
    
    if(EntitlementToAdd.isEmpty() == false){
        AssignEntitlementOnCase.assignEntitlement(cases, EntitlementToAdd);
        }
//        trigger.new[0].Action_needed_by__c = '3rd Party';
}

 

 

public class AssignEntitlementOnCase{

    public static void assignEntitlement(List<Case> cases, List<Entitlement> EntitlementToAdd) {
        List<Case> CasesToUpdate = [Select Id, EntitlementId From Case cases Where EntitlementId = null limit 3];
        if(CasesToUpdate.isEmpty() == false){
            for(Case c : cases){
            c.EntitlementId = EntitlementToAdd[0].Id;
            }
        }
    }
}

 

 

 

Hi,

 

I'm working on a trigger to call a class which assigns an Entitlement on Cases according to the Priority and Account on the case. The trigger and class both work for cases created internally, but won't work for customers through the customer portal. Below are the triggers and class involved. The customer portal profiles have Read access for the Entitlement object. Any help would be greatly appreciated!

 

trigger AssignEntitlementTrigger on Case (before insert){

    Case[] cases = trigger.new;
    List<Id> CaseAccounts = new List<Id>();
    List<Entitlement> EntitlementToAdd = new List <Entitlement>();
    Case cA = cases[0];
      if(cases[0].Priority == 'Critical'){
            EntitlementToAdd = [Select Id From Entitlement 
                                    Where AccountId = :cA.AccountId and 
                                    Entitlement.Support_process__c = 'Critical' 
                  limit 1];
//                trigger.new[0].Action_needed_by__c = 'BigMachines';
        }
      else if(cases[0].Priority != 'Critical'){            
            if(cases[0].Support_Product__c == 'Premium'){
                   
              EntitlementToAdd = [Select Id From Entitlement 
                                    Where AccountId = :cA.AccountId and Entitlement.Support_Process__c = 'Premier'
                                    limit 1];
//                   trigger.new[0].Action_needed_by__c = 'Customer';
            }
        else {               
            EntitlementToAdd = [Select Id From Entitlement
                                Where AccountId = :cA.AccountId and Entitlement.Support_Process__c = 'Standard'
                                limit 1];
//         trigger.new[0].Action_needed_by__c = 'User';
        }
       }
    
    if(EntitlementToAdd.isEmpty() == false){
        AssignEntitlementOnCase.assignEntitlement(cases, EntitlementToAdd);
        }
//        trigger.new[0].Action_needed_by__c = '3rd Party';
}

 

 

public class AssignEntitlementOnCase{

    public static void assignEntitlement(List<Case> cases, List<Entitlement> EntitlementToAdd) {
        List<Case> CasesToUpdate = [Select Id, EntitlementId From Case cases Where EntitlementId = null limit 3];
        if(CasesToUpdate.isEmpty() == false){
            for(Case c : cases){
            c.EntitlementId = EntitlementToAdd[0].Id;
            }
        }
    }
}