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