davidh2892249
davidh2892249
02-05-2019
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
wodnicki
MVP
wodnicki
MVP
02-05-2019
Hi,
The dataPolicy rules are undocumented, but if you're implementing validation it should hew to rfc 5322 compliance anyway:
Thanks,
-Jon
DavidKangni
MVP
DavidKangni
MVP
03-05-2019
Hi David,
You can find it under Administration>Configuration> Javascript codes
it's called dataPolicy.js
Thanks
David
wodnicki
MVP
wodnicki
MVP
06-05-2019
That's a subset of the dataPolicy functionality (missing emailOrScript, hyphenIdentifier), looks like part of interaction module's js xtk implementation. I wonder if the c++ xtk matches, and why they didn't just copy the rfc regex..
DarrenBiz
DarrenBiz
06-05-2019
Hi davidk23955130 - I just tested that code you highlighted above with an invalid email address - "blah23/2456@gmail.com" - it passes those tests but you can't insert it into the recipient table. The email addresses passes all RFC5322 tests I have thrown at it.
Can anyone tell us the exact data policy that Adobe Campaign uses to validate an email? We need this.
DavidKangni
MVP
DavidKangni
MVP
07-05-2019
email is defined as string using constraint on data policy.
If you need to use any of the special characters literally, you must escape it by putting a backslash in front of it e.g /a\*b/ to escape '*'. ACC's regex in the data policy doesn't have the escaping special characters capability as it's using an old javascript regex.
Thanks
David
DarrenBiz
DarrenBiz
07-05-2019
Hi David - I tried what you said and escaped the special characters in the email, but the recipient write still fails. Here is my test code:
var email = "blah23\/2456@gmail.com";
var firstName = "Ford";
var lastName = "Prefect";
var mobile = "0000888999"
//RFC5322 email regex
var regexEmail = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var pattEmail = new RegExp(regexEmail);
//this will pass
if(pattEmail.test(email)) {
var recipientId = xtk.session.GetNewIds(1);
//this will fail
xtk.session.Write(
<recipient _operation="insert"
xtkschema="nms:recipient"
id={recipientId}
email={email}
firstName={firstName}
lastName={lastName}
mobilePhone={mobile} >
<folder name="nmsRootRecipient"/>
</recipient>
);
} else {
logWarning("Bad email: " + email);
}
DarrenBiz
DarrenBiz
07-05-2019
And again using Adobe dataPolicy.js email test instead of the RFC5322 regex:
var email = "blah23\/2456@gmail.com";
var firstName = "Ford";
var lastName = "Prefect";
var mobile = "0000888999"
var testResult = null;
//dataPolicy.js email test
var aPart = email.split("@");
if (aPart.length === 2 && aPart[0].match(/^[\S]+$/) &&
aPart[1].match(/^([\w\-]+\.)+[\w\-]+$/)) {
testResult = email.toLowerCase();
} else {
// TODO shouldn't we return an empty string?
testResult = null;
}
logInfo("Result of Adobe email test: " + testResult);
//this will pass
if(testResult) {
var recipientId = xtk.session.GetNewIds(1);
//this will fail
xtk.session.Write(
<recipient _operation="insert"
xtkschema="nms:recipient"
id={recipientId}
email={email}
firstName={firstName}
lastName={lastName}
mobilePhone={mobile} >
<folder name="nmsRootRecipient"/>
</recipient>
);
} else {
logWarning("Bad email: " + email);
}
DavidKangni
MVP
DavidKangni
MVP
07-05-2019
it's normal because your attribute in your recipient schema is still using the default dataPolicy
Thanks
David
DarrenBiz
DarrenBiz
07-05-2019
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