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
Hiral Patel 25Hiral Patel 25 

{ con.Phone.AddError ('Pl

 why i am showing this error :Variable does not exist: Phone

trigger Phone_Email_Validation on Contact (before insert) 
{
  if (Trigger.Isbefore && Trigger.IsInsert)
  {
      for (Contact con : Trigger.New)
      {
          if (con.Phone == Null || con.Phone == '')
          {
              con.Phone.AddError ('Please Enter a valid Phone Number');
          }
          Else
              if(con.Email == Null || con.Email == '')
          {
              con.Email.AddError ('Please Enter a valid Email Address');
          }
      }
  }
}
SwethaSwetha (Salesforce Developers) 
HI Hiral,
I copied the same code in my org and was able to save it without any issues. Can you try renaming the trigger and see if that fixes the issue?

See related:https://developer.salesforce.com/forums/?id=906F0000000kH8EIAU

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Hiral Patel 25Hiral Patel 25
No, it doesn't. work. I am showing same error i dont know why??
ravi soniravi soni
hi Hiral,
I did check your code, code is working fine and in my org it's throwing error on praticular field's phone and email.
I think you should reload your page once any try again.
let me know it's working or not and mark the best if it works.
Thank you