You need to sign in to do that
Don't have an account?
Riby 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');
}
}
}
}
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');
}
}
}
}
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');
}
}
}
}
{
//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.
}
}
}
}