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
thirupathi gthirupathi g 

create a Trigger in case,(bulkification process) when the status is “Escalated” and old status is “New” and description is null. Then display an error message that, “Please provide description to escalate the case”.

Best Answer chosen by thirupathi g
Maharajan CMaharajan C
Hi,

Use the before update trigger.
 
trigger CaseTrigger on Case (before update) {        
    if(Trigger.IsBefore && Trigger.IsUpdate){
        for(case cs : Trigger.New){
            if(cs.Status == 'Escalated' && Trigger.oldMap.get(cs.Id).status == 'New'  && String.isBlank(cs.Description)){
                cs.addError( ' Please provide description to escalate the case ' );
            }
        }
    }
}

Thanks,
Maharajan.C

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Tirupathi,

You can try the below snippet:
 
trigger CaseTrigger on Case(before insert)
{
if(trigger.isbefore && trigger.isinsert)
{
for(Case caseRec: trigger.new)
{
if(Trigger.oldmap.get(caseRec.id).Status =='New' && caseRec.Status== 'Escalated' && 
String.isBlank(caseRec.Description))
{
caseRec.adderror('Description cannot be empty while escalating');
}
}
}
}
Please note this is a sample snippet and you need to modify it accordingly.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Maharajan CMaharajan C
Hi,

Use the before update trigger.
 
trigger CaseTrigger on Case (before update) {        
    if(Trigger.IsBefore && Trigger.IsUpdate){
        for(case cs : Trigger.New){
            if(cs.Status == 'Escalated' && Trigger.oldMap.get(cs.Id).status == 'New'  && String.isBlank(cs.Description)){
                cs.addError( ' Please provide description to escalate the case ' );
            }
        }
    }
}

Thanks,
Maharajan.C
This was selected as the best answer
Malika Pathak 9Malika Pathak 9
Hi Tirupathi,
trigger CaseTrigger on Case(before insert){
     if(trigger.isbefore && trigger.isinsert)
         {
		   caseRecordError.getCase(Trigger.New,Trigger.oldMap);
		   }
		   }
		   
		   public class caseRecordError{
		   
		   public static void getCase(List<Case> caseList, Map<Id,Case> oldmapValue){
		   for(Case Case caseRec:caseList){
		   
		   if(oldmapValue.get(caseRec.id).Status =='New' && caseRec.Status== 'Escalated' && 
              String.isBlank(caseRec.Description))
               {
                 caseRec.adderror('Description cannot be empty while escalating');
               }
		       }
		   
		   }
		   
		   
		   }

Kindly mark this as the best answer, If you find this answer helpful.