Constraint / dataPolicy on Email Address | Community
Skip to main content
davidh2892249
Level 5
May 2, 2019

Constraint / dataPolicy on Email Address

  • May 2, 2019
  • 3 replies
  • 27353 views

Hi there,

I'm aware there is a constraint on the email address field on the Recipient table (aka a data policy) that only allows a "valid format" email address to be stored in this field.

Does anyone know where the "rules" of the constraint is documented?

I'd like to be able to replicate the logic when exporting data from a CRM system that exports data to Adobe Campaign, so these records can be filtered at source.

Thanks

David

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Jonathon_wodnicki
Community Advisor
Community Advisor
May 2, 2019

Hi,

The dataPolicy rules are undocumented, but if you're implementing validation it should hew to rfc 5322 compliance anyway:

Thanks,

-Jon

DavidKangni
Community Advisor
Community Advisor
May 3, 2019

Hi David,

You can find it under Administration>Configuration> Javascript codes

it's called dataPolicy.js

Thanks

David

David Kangni
DarrenBiz
Level 6
May 7, 2019

it's normal because your attribute in your recipient schema is still using the default dataPolicy

Thanks

David


So what is the exact test for an invalid email where the recipient schema uses the default dataPolicy? I need to be able to capture these invalid emails before it gets to the write stage

DarrenBiz
Level 6
May 8, 2019

So another piece to this puzzle (provided by Support) is the option value for the valid characters in an email address XtkEmail_Characters. I tested this value and this Option value is definitely being used by the mystery validation function to check for valid characters in the email before the write happens.

What they couldn't confirm was how this was applied to the email address (local-part or domain or both). Nor could they confirm what other checks were being performed before the recipient Write was attempted.

DarrenBiz
Level 6
June 13, 2019

OK - I finally have an answer on how ACC determines a valid email. It took way more effort than I expected but we got an answer:

So I am assuming that the first part of this response is the dataPolicy check and the second is a regex against the XtkEmail_Characters option. e.g. something like this

loadLibrary("xtk:shared/nl.js");

loadLibrary("xtk:shared/dataPolicy.js");

var email = "blah232456@gmail.com";

/**

*

* Function to determine if an email is valid for the Adobe Campaign

* database checks. This process checks using the default email dataPolicy

* and the option value XtkEmail_Characters.

*

* @param email {string} email address to test

* @return true(valid) | false(invalid)

*

**/ 

function isValidAdobeEmail( email ) { 

var patt = "[^@" + getOption('XtkEmail_Characters').replace(/[.*+?\-^${}()|[\]\\]/g, '\\\$&') + "]";

//logInfo("EmailFunctions.js::isValidAdobeEmail() - Escaped XtkEmail_Characters: " + patt);

var regex = new RegExp(patt, "g"); 

var testFlag = !regex.test(email); 

//logInfo("Result of XtkEmail_Characters test: " + ((testFlag)?"valid":"invalid"));

var dataPolicyResult = !NL.isEmpty(NL.DataPolicy.filter("email", email)); 

//logInfo("Result of dataPolicy email test: " + ((!NL.isEmpty(dataPolicyResult))?"valid":"invalid"));

return testFlag && dataPolicyResult; 

}

//Test the email

if( isValidAdobeEmail(email) ) {

  //email address is valid

} else {

  //email is invalid

}

Edit: minimised the code

Jonathon_wodnicki
Community Advisor
Community Advisor
June 14, 2019

Hi,

No there is no regex here. The code is matching characters after splitting the string into @ and .

Pseudocode in js would be:

str.split(/[@.]/).filter(function(_){

    return _.match(/^[XtkEmail_Characters as a character class]+$/);

}).length >= 3

Thanks,

-Jon