+ Start a Discussion
sudhirn@merunetworks.comsudhirn@merunetworks.com 

Formual field to check domain names contains in the list

Hi, 
 
 In account we need to add a validtion on email domain field which is in email format eg. sudhir@gmail.com

 Field name is Email_Domain__c

 if any of the mail contains “gmail.com”, “hotmail.com”, “yahoo.com”, “gmx.de”, “googledomain.com”, “mail.ru”, “web.de”, “live.com”, “aol.com”, “gmx.net”, “yandex.ru”, “me.com”, “msn.com”, “comcast.com”, “hushmail.com”, “yahoo.de”, “hotmail.co.uk”, “lavabit.com”, “sbcglobal.net”, “safe-mail.net”, “ymail.com”, “yahoo.co.uk”

It should through message saying personal email cannot be entered.

Thanks
Sudhir

Best Answer chosen by sudhirn@merunetworks.com
Deepak GulianDeepak Gulian
OR(
CONTAINS(Email_Domain__c,"gmail.com"),
CONTAINS(Email_Domain__c,"yahoo.com")
and so on.....
)

All Answers

BRTRAJBRTRAJ
write a simple trigger. throwing error with formula might not work here.
sudhirn@merunetworks.comsudhirn@merunetworks.com
I wrote a trigger which will update domain now with forumal i need to validate non of the below domain should contain in the field Email_Domain__c

if any of the mail contains “gmail.com”, “hotmail.com”, “yahoo.com”, “gmx.de”, “googledomain.com”, “mail.ru”, “web.de”, “live.com”, “aol.com”, “gmx.net”, “yandex.ru”, “me.com”, “msn.com”, “comcast.com”, “hushmail.com”, “yahoo.de”, “hotmail.co.uk”, “lavabit.com”, “sbcglobal.net”, “safe-mail.net”, “ymail.com”, “yahoo.co.uk”

Thanks
Sudhir
Deepak GulianDeepak Gulian
OR(
CONTAINS(Email_Domain__c,"gmail.com"),
CONTAINS(Email_Domain__c,"yahoo.com")
and so on.....
)
This was selected as the best answer
Nagendra Prasad ChNagendra Prasad Ch
OR( 
Right(Domain_Email__c , (LEN(Domain_Email__c)-FIND("@", Domain_Email__c ))) = "gmail.com",
Right(Domain_Email__c , (LEN(Domain_Email__c)-FIND("@", Domain_Email__c ))) = "hotmail.com",
Right(Domain_Email__c , (LEN(Domain_Email__c)-FIND("@", Domain_Email__c ))) = "yahoo.com",
Right(Domain_Email__c , (LEN(Domain_Email__c)-FIND("@", Domain_Email__c ))) = "gmx.de",
Right(Domain_Email__c , (LEN(Domain_Email__c)-FIND("@", Domain_Email__c ))) = "googledomain.com"
)
ajay rawat 14ajay rawat 14
Hi Sudhirn
             Try below formula in validation rule

CONTAINS('gmail.com:hotmail.com:yahoo.com:gmx.de:googledomain.com:mail.ru:web.de:live.com:aol.com:gmx.net:yandex.ru:me.com:msn.com:comcast.com:hushmail.com:yahoo.de:hotmail.co.uk:lavabit.com:sbcglobal.net:safe-mail.net:ymail.com:yahoo.co.uk',RIGHT(Email_Domain__c,LEN(Email_Domain__c) -FIND('@',Email_Domain__c)))

Thanks
Ajay Rawat