🐛Don't overwrite close.io nces custom field data

This commit is contained in:
Matt Lott 2016-08-30 15:32:22 -07:00
parent 652c5237aa
commit 3387e5ee34

View file

@ -506,20 +506,11 @@ class CocoLead {
if (!currentCustom['Lead Origin']) { if (!currentCustom['Lead Origin']) {
putData['custom.Lead Origin'] = this.getLeadOrigin(); putData['custom.Lead Origin'] = this.getLeadOrigin();
} }
for (const email in this.contacts) { for (const email in this.contacts) {
const props = this.contacts[email].trial.properties; const props = this.contacts[email].trial.properties;
if (props) { if (props) {
let haveNcesData = false;
for (const prop in props) { for (const prop in props) {
if (/nces_/ig.test(prop)) { if (!currentCustom[`demo_${prop}`] && (commonTrialProperties.indexOf(prop) >= 0 || /nces_/ig.test(prop))) {
haveNcesData = true;
putData[`custom.demo_${prop}`] = props[prop];
}
}
for (const prop in props) {
// Always overwrite common props if we have NCES data, because other fields more likely to be accurate
if (commonTrialProperties.indexOf(prop) >= 0 && (haveNcesData || !currentCustom[`demo_${prop}`] || currentCustom[`demo_${prop}`] !== props[prop] && currentCustom[`demo_${prop}`].indexOf(props[prop]) < 0)) {
putData[`custom.demo_${prop}`] = props[prop]; putData[`custom.demo_${prop}`] = props[prop];
} }
} }