• saikiran madugula
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
In this trigger apex, we can give Pincode__c text field. Pincode must be only 6 digits. If Pincode is exceeded 6 digits then we can show error message as "Pincode must be 6 digits"
I tried above code but not getting output:-
trigger Exact_Six_Digits on Customer__c (before insert) {
    for(Customer__c u : trigger.new){
        if(u.Pincode__c.length()!=6){
            u.Pincode__c.adderror('Pincode must be 6 digits');
        }
    }
}
Please give me suggestions for how to implement the condition. Thank you !