Groovy Support for Email Address Format Validation

You can add email addresses for accounts or contacts using the respective UI pages or REST APIs. While entering these email addresses, the format of the email address should be validated.

You can use Groovy scripts to specify the rules to validate email address formats.

For more information on Groovy scripting, see Oracle Applications Cloud Groovy Scripting Reference guide. For more information about REST APIs, see the REST API for CX Sales and Fusion Service guide.

The following code is a sample for validating email addresses:

def regex = /(?i)^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/ 
def email = getAttribute('ListEmailAddress'); 
def EmailCollection = Email ;
EmailCollection.reset();

if (email == null)
{
while(EmailCollection.hasNext()){
def emailRec = EmailCollection.next() 
email = emailRec.EmailAddress
if (!(email =~ regex)){ 
throw new oracle.jbo.ValidationException("Populate email in the appropriate format (example someone@oracle.com)") 
}  
} 
}
else
if (!(email =~ regex)){ 
throw new oracle.jbo.ValidationException("Populate email in the appropriate format (example someone@oracle.com)") 
}