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
Riby VargheseRiby Varghese 

Apex trigger is not working

Hi, I want to fire a trigger when the amount is greater  than 100, but it's not working 
trigger caseclosetrigger on Case(before insert) 
{
   //Loop Through All the records which are inside Trigger.new
   for(Case cs : Trigger.new)
   {
      //logic to check value
      if(cs.Appeasement_Type__c=='GoodWill Points')
      {
         if(cs.Appeasement_Amount__c <=100)
           {
        cs.addError('amount cant be less than 100');
           }
      }
   }
}
Fazurulla GagangapalliFazurulla Gagangapalli
Hi Riby,

Try this below code and let me know if in case any query.

trigger caseclosetrigger on Case(before insert) 
{
   //Loop Through All the records which are inside Trigger.new
   for(Case cs : Trigger.new)
   {
      //logic to check value
      if(cs.Appeasement_Type__c=='GoodWill Points')
      {
         if(cs.Appeasement_Amount__c >100)
           {
        cs.addError('amount cant be less than 100');
           }
      }
   }
}
Shamsi 110Shamsi 110
trigger caseclosetrigger on Case(before insert) 
{
   //Loop Through All the records which are inside Trigger.new
   for(Case cs : Trigger.new)
   {
      //logic to check value
      if(cs.Appeasement_Type__c=='GoodWill Points')
      {
           if(cs.Appeasement_Amount__c <=100)
           {
                cs.addError('amount cant be less than 100');
           }
           else
           {
           // Your logic to run.
           }
      }
   }
}