+ Start a Discussion
pooja biswaspooja biswas 

validation rule to fire only during edit

Hi
I need to have a validation rule fire only when Lead object Email field is edited and not when inserted.
I did something like this on Lead object.

NOT(REGEX( Email  ,'([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3}\\.[a-z]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})'))

so this works when a new Lead is inserted or edit  and email not proeprly specified.

Now I did like this
NOT(REGEX( Email  ,'([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3}\\.[a-z]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})')) && NOT(ISNEW())

but its not working.
Need help on this.

thanks
pooja


 
Best Answer chosen by pooja biswas
Roshni RahulRoshni Rahul
Hi pooja,

AND(ISCHANGED(Email), NOT(ISNEW())) is working for me.
Actually you dont have to check the NOT(REGEX( Email  ,'([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3}\\.[a-z]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})'))  because email field throws that error if email is not in proper syntax. Standard validation is performed on it. Its working perfectly for me. If any problem, you can ask me. If working, please mark this as best answer

All Answers

Roshni RahulRoshni Rahul
Hi pooja, 

try this out
NOT(REGEX( Email  ,'([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3}\\.[a-z]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})')) && NOT(ISNEW()) && ISCHANGED( )
Roshni RahulRoshni Rahul
Those which contains ISCHANGED( ) says if there is a change in exixting record ,rule will fire .
pooja biswaspooja biswas
Hi roshni
I tried but its not working.
I did like this also  (Myvalidation rule) && NOT(ISNEW()) && NOT(ISCHANGED(Email )) but its not working.

Thanks
Pooja


 
Roshni RahulRoshni Rahul
Hi pooja,

AND(ISCHANGED(Email), NOT(ISNEW())) is working for me.
Actually you dont have to check the NOT(REGEX( Email  ,'([a-zA-Z0-9_\\-\\.]+)@((\\[a-z]{1,3}\\.[a-z]{1,3}\\.[a-z]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})'))  because email field throws that error if email is not in proper syntax. Standard validation is performed on it. Its working perfectly for me. If any problem, you can ask me. If working, please mark this as best answer
This was selected as the best answer
pooja biswaspooja biswas
Hi roshni
Thanks, I overlooked this .

Its working