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
Vinny12Vinny12 

Trigger Validation

Can someone provide me an example of validations using triggers?

@anilbathula@@anilbathula@

Hi Vinny12

here is trigger which validate a phone number on account.

trigger validatephone on Account (before insert,before update) {
 for(Account a:Trigger.New){
    if( a.phone==null){
       a.Phone.addError('plz enter phone number');
   }
 }
}

Vinny12Vinny12

Hey thanks anil .