diff --git a/process/Leadimport_lib/process.js b/process/Leadimport_lib/process.js index 6b5411de5e50467baf46d387ebd79b005dbf6f8c..66db58645e63f46b287f4f1474ac2b2f0f537d95 100644 --- a/process/Leadimport_lib/process.js +++ b/process/Leadimport_lib/process.js @@ -153,6 +153,7 @@ LeadImportUtils.loadImportFile = function(pBinId, pFieldSep, pFieldLimit, pRecor */ LeadImportUtils.importData = function(pDataFields, pDataTypes, pFieldDef, pFieldValues, pImportDefID, pAttrObject, pSource, pUser, pDate) { + // set the mappings LeadImportUtils.mapping = LeadImportUtils.getMapping(pImportDefID); var LeadValues = LeadImportUtils.setValues(pDataFields["LEAD"], pFieldDef, pFieldValues); // set the Lead values @@ -222,6 +223,14 @@ LeadImportUtils.importData = function(pDataFields, pDataTypes, pFieldDef, pField return [leadId, persForDubCheck, orgsForDubCheck]; } + +/** + * get all Mapping to a Leadimport + * + * @param {String} pleadimportId the ID of a Leadimport + * + * @return {Object} an associative array in format arr[fieldname][inputvalue] --> outputvalue + */ LeadImportUtils.getMapping = function(pleadimportId) { let tempData = {}; @@ -230,7 +239,7 @@ LeadImportUtils.getMapping = function(pleadimportId) .where("LEADIMPORTMAPPINGASSISTANT.LEADIMPORT_ID", pleadimportId) .table().forEach(function (d) { if (tempData[d[0]] == undefined ) - tempData[d[0]] = {} //[[d[1], d[2]]] + tempData[d[0]] = {} tempData[d[0]][d[1]] = d[2]; }); return tempData; @@ -325,6 +334,7 @@ LeadImportUtils.setValues = function(pFields, pFieldDef, pFieldValues) LeadImportUtils.mapping[pFieldDef[i][1]] != undefined && LeadImportUtils.mapping[pFieldDef[i][1]][pFieldValues[pFieldDef[i][0]]] != undefined) { + // mapping is available and is set pFieldValues[pFieldDef[i][0]] = LeadImportUtils.mapping[pFieldDef[i][1]][pFieldValues[pFieldDef[i][0]]]; }