Account: Script to validate the URL and All E-mails (Doc ID 2197415.1)

Last updated on OCTOBER 26, 2016

Applies to:

Oracle Fusion Sales Cloud Service - Version 11.1.11.1.0 and later
Information in this document applies to any platform.

Goal

(R11) On Account object customer has the following script added as a Before Update trigger:


def error = " "
def emailCollection = Email
emailCollection.reset()
def regex = /^[_A-Za-z0-9-\\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$/
while(emailCollection.hasNext())
{
def emailRec = emailCollection.next()
 def email = emailRec.EmailAddress
if(email.matches(regex))
 {
  return true
 }
 else
 {
  error = error + "Please enter valid Email address"
 }
}
def url
def accountID = getAttribute('PartyId')
def vo = newView('OrganizationProfile')
def vc = newViewCriteria(vo)
def vcr = vc.createRow()
def vci = vcr.ensureCriteriaItem("PartyId")
 vci.setOperator('=')
 vci.setValue(accountID)
 vc.insertRow(vcr)
 vo.appendViewCriteria(vc)
 vo.executeQuery()
while (vo.hasNext())
{
def curRow = vo.next()
url = curRow.getAttribute("PrimaryURL");
}
if(url!=null && (isAttributeChanged('PrimaryURL')))
{
 if(url.matches(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/|www\.)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/))
 {
  return true
 }
 else
 {
  error = error + "Please enter valid URL"
 }
}
if(error!= " ")
{
 throw new oracle.jbo.ValidationException("Error: "+ error)
}
else
{
 return true
}

The purpose of this trigger is to not allow editing and then saving Account records with invalid values for URL Address/ All E-Mails. The script is working when they are changing any other values than URL Addresses/All Emails -> for example add invalid values for URL Addresses/All Emails, change the account name and Save -> the error will be thrown. However, if changing URL/All Emails only, then the trigger is not getting fired.

Why is this happening?
 

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms