diff --git a/entity/CommRestriction_Entity/CommRestriction_Entity.aod b/entity/CommRestriction_Entity/CommRestriction_Entity.aod index af5659bb88ee1ee264431feddb0a1ff3b529578a..b1604aa94b0cfb68fd202ff113e3586b76268cfa 100644 --- a/entity/CommRestriction_Entity/CommRestriction_Entity.aod +++ b/entity/CommRestriction_Entity/CommRestriction_Entity.aod @@ -5,6 +5,7 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/CommRestriction_Entity/documentation.adoc</documentation> <contentTitleProcess>%aditoprj%/entity/CommRestriction_Entity/contentTitleProcess.js</contentTitleProcess> + <contentTitleProcess>%aditoprj%/entity/CommRestriction_Entity/contentTitleProcess.js</contentTitleProcess> <titlePlural>Advertising bans</titlePlural> <recordContainer>db</recordContainer> <entityFields> diff --git a/entity/ImportField_Entity/ImportField_Entity.aod b/entity/ImportField_Entity/ImportField_Entity.aod index 98e67835fe5b72426e734a6ad809647ae9ff9948..fb47af9cfe9e5cc16060f6155577916e6a0fd57b 100644 --- a/entity/ImportField_Entity/ImportField_Entity.aod +++ b/entity/ImportField_Entity/ImportField_Entity.aod @@ -3,6 +3,9 @@ <name>ImportField_Entity</name> <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/ImportField_Entity/documentation.adoc</documentation> + <siblings> + <element>Leadimport_entity</element> + </siblings> <grantCreate v="false" /> <grantDelete v="false" /> <contentTitleProcess>%aditoprj%/entity/ImportField_Entity/contentTitleProcess.js</contentTitleProcess> diff --git a/entity/Leadimport_entity/Leadimport_entity.aod b/entity/Leadimport_entity/Leadimport_entity.aod index 8c953c11449eb6ea743aacc9520ee0718ab26114..1036476970eb43d306f04b06c997b1c99d3afc60 100644 --- a/entity/Leadimport_entity/Leadimport_entity.aod +++ b/entity/Leadimport_entity/Leadimport_entity.aod @@ -5,6 +5,9 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/Leadimport_entity/documentation.adoc</documentation> <icon>NEON:IMPORT</icon> + <siblings> + <element>ImportField_Entity</element> + </siblings> <grantUpdate v="true" /> <grantUpdateProcess>%aditoprj%/entity/Leadimport_entity/grantUpdateProcess.js</grantUpdateProcess> <grantDelete v="true" /> @@ -65,6 +68,7 @@ <name>STATUS</name> <title>Status</title> <consumer>KeywordImportStatus</consumer> + <groupable v="true" /> <state>READONLY</state> <valueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/status/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/status/displayValueProcess.js</displayValueProcess> @@ -74,6 +78,7 @@ <title>Import date</title> <contentType>DATE</contentType> <resolution>DAY</resolution> + <groupable v="false" /> <valueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/leadimport_date/valueProcess.js</valueProcess> </entityField> <entityField> @@ -97,6 +102,7 @@ <isObjectAction v="false" /> <isSelectionAction v="false" /> <iconId>VAADIN:INBOX</iconId> + <stateProcess>%aditoprj%/entity/Leadimport_entity/entityfields/transferdata/stateProcess.js</stateProcess> </entityActionField> <entityField> <name>SENTENCESEPARATOR</name> @@ -104,6 +110,7 @@ <mandatory v="true" /> <dropDownProcess>%aditoprj%/entity/Leadimport_entity/entityfields/sentenceseparator/dropDownProcess.js</dropDownProcess> <textInputAllowed v="true" /> + <displayValueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/sentenceseparator/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>FIELDSEPARATOR</name> @@ -111,6 +118,7 @@ <mandatory v="true" /> <dropDownProcess>%aditoprj%/entity/Leadimport_entity/entityfields/fieldseparator/dropDownProcess.js</dropDownProcess> <textInputAllowed v="true" /> + <displayValueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/fieldseparator/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>FIELDDELIMITERS</name> @@ -118,10 +126,12 @@ <mandatory v="true" /> <dropDownProcess>%aditoprj%/entity/Leadimport_entity/entityfields/fielddelimiters/dropDownProcess.js</dropDownProcess> <textInputAllowed v="true" /> + <displayValueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/fielddelimiters/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>IMPORTSOURCE</name> <title>Import source</title> + <groupable v="true" /> <mandatory v="true" /> </entityField> <entityConsumer> @@ -176,11 +186,7 @@ </entityProvider> <entityConsumer> <name>ImportFieldID</name> - <dependency> - <name>dependency</name> - <entityName>ImportField_Entity</entityName> - <fieldName>LeadImportIds</fieldName> - </dependency> + <onValidation>%aditoprj%/entity/Leadimport_entity/entityfields/importfieldid/onValidation.js</onValidation> <children> <entityParameter> <name>LeadImportID</name> @@ -358,6 +364,13 @@ <name>#PROVIDER_AGGREGATES</name> <useAggregates v="true" /> </entityProvider> + <entityActionField> + <name>ReloadTransferdData</name> + <title>Search for new Entries</title> + <onActionProcess>%aditoprj%/entity/Leadimport_entity/entityfields/reloadtransferddata/onActionProcess.js</onActionProcess> + <isObjectAction v="false" /> + <iconId>VAADIN:REFRESH</iconId> + </entityActionField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Leadimport_entity/entityfields/fielddelimiters/displayValueProcess.js b/entity/Leadimport_entity/entityfields/fielddelimiters/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..60728b855572f3068a1d7296e2a9e23550eb97d5 --- /dev/null +++ b/entity/Leadimport_entity/entityfields/fielddelimiters/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.translate"); +import("system.vars"); +import("system.result"); + +result.string(translate.text(vars.get("$this.value"))); \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/fieldseparator/displayValueProcess.js b/entity/Leadimport_entity/entityfields/fieldseparator/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..60728b855572f3068a1d7296e2a9e23550eb97d5 --- /dev/null +++ b/entity/Leadimport_entity/entityfields/fieldseparator/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.translate"); +import("system.vars"); +import("system.result"); + +result.string(translate.text(vars.get("$this.value"))); \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/importfieldid/onValidation.js b/entity/Leadimport_entity/entityfields/importfieldid/onValidation.js new file mode 100644 index 0000000000000000000000000000000000000000..a49ff8581aa41f29208cda5ef0f8bab7b990d3eb --- /dev/null +++ b/entity/Leadimport_entity/entityfields/importfieldid/onValidation.js @@ -0,0 +1,60 @@ +import("system.translate"); +import("system.result"); +import("Sql_lib"); +import("system.vars"); + +var attributeChanges = { + "LASTNAME" : [], + "NAME" : [] +}; + +var idMapping = {}; +var consumerField = "ImportFieldID"; +var changedRows = vars.get("$field." + consumerField + ".changedRows"); + +newSelect(["IMPORTFIELD.MAPPINGFIELD", "IMPORTFIELD.IMPORTFIELDID"]) + .from("IMPORTFIELD") + .where("IMPORTFIELD.LEADIMPORT_ID", "9f77f90f-cc49-456f-8d20-2fa86bf6fdf4") + .and( + newWhere("IMPORTFIELD.MAPPINGFIELD", "LASTNAME") + .or("IMPORTFIELD.MAPPINGFIELD", "NAME")) + .table() + .forEach(function (row) { + _addNewID(row[0], row[1]); + }); + +if (changedRows) +{ + changedRows.forEach(function (row) + { + if (!idMapping[row.IMPORTFIELDID]) + { + _addNewID(row.MAPPINGFIELD, row.IMPORTFIELDID); + } + else + { + var index = attributeChanges[idMapping[row.IMPORTFIELDID]].indexOf(row.IMPORTFIELDID); + if (index > -1) + { + attributeChanges[idMapping[row.IMPORTFIELDID]].splice(index, 1); + _addNewID(row.MAPPINGFIELD, row.IMPORTFIELDID); + } + } + + }); +} + +if (!attributeChanges.NAME.length && !attributeChanges.LASTNAME.length) +{ + result.string(translate.text("The Import Fields \"Lastname\" or \"Organisation\" have to be mapped!")); +} + +function _addNewID (pMappingField, pImportId) +{ + if (attributeChanges[pMappingField]) + { + attributeChanges[pMappingField].push(pImportId); + idMapping[pImportId] = pMappingField; + } +} + \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/reloadtransferddata/onActionProcess.js b/entity/Leadimport_entity/entityfields/reloadtransferddata/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..859ea6ca00cc4430746641e87e886e9c0bfa073c --- /dev/null +++ b/entity/Leadimport_entity/entityfields/reloadtransferddata/onActionProcess.js @@ -0,0 +1,2 @@ +import("system.neon"); +neon.refresh(); \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/sentenceseparator/displayValueProcess.js b/entity/Leadimport_entity/entityfields/sentenceseparator/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..60728b855572f3068a1d7296e2a9e23550eb97d5 --- /dev/null +++ b/entity/Leadimport_entity/entityfields/sentenceseparator/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.translate"); +import("system.vars"); +import("system.result"); + +result.string(translate.text(vars.get("$this.value"))); \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/sentenceseparator/dropDownProcess.js b/entity/Leadimport_entity/entityfields/sentenceseparator/dropDownProcess.js index b955dae75d3b2e600f98bdae783e378cff727af3..6ba802190fa0bc641f9a6c53aa6b8fdf9f1250c7 100644 --- a/entity/Leadimport_entity/entityfields/sentenceseparator/dropDownProcess.js +++ b/entity/Leadimport_entity/entityfields/sentenceseparator/dropDownProcess.js @@ -1,4 +1,6 @@ import("system.translate"); import("system.result"); -result.object([["carriage return and line feed", translate.text("carriage return and line feed")]]) \ No newline at end of file +result.object([ + ["carriage return and line feed", translate.text("carriage return and line feed")] +]); \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/transferdata/stateProcess.js b/entity/Leadimport_entity/entityfields/transferdata/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..ed97ad26cf42805e0645ab99f863379278539ea2 --- /dev/null +++ b/entity/Leadimport_entity/entityfields/transferdata/stateProcess.js @@ -0,0 +1,19 @@ +import("Sql_lib"); +import("system.result"); +import("system.vars"); +import("Leadimport_lib"); +import("system.neon"); + +let leadimportID = vars.get("$field.LEADIMPORTID"); +let count = newSelect(["count(*)"]) + .from("IMPORTFIELD") + .where("IMPORTFIELD.LEADIMPORT_ID", leadimportID) + .and( + newWhere("IMPORTFIELD.MAPPINGFIELD", "LASTNAME") + .or("IMPORTFIELD.MAPPINGFIELD", "NAME") + ).cell(); + +if (count > 0) + result.string(neon.COMPONENTSTATE_EDITABLE); +else + result.string(neon.COMPONENTSTATE_DISABLED); \ No newline at end of file diff --git a/entity/Leadimport_entity/recordcontainers/db/onDBUpdate.js b/entity/Leadimport_entity/recordcontainers/db/onDBUpdate.js index 276fa07844206e963e7c366faa238498602abebd..408e3da8f19a03687ee4d6292046c387cde1e56a 100644 --- a/entity/Leadimport_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Leadimport_entity/recordcontainers/db/onDBUpdate.js @@ -6,42 +6,53 @@ import("KeywordRegistry_basic"); import("Keyword_lib"); import("Binary_lib"); import("Leadimport_lib"); +import("ExportTemplate_lib"); +import("Binary_lib"); +import("Document_lib"); +import("Sql_lib"); import("system.db"); import("system.vars"); -import("system.util"); -import("Document_lib"); + + +var binId; +var assignmentRowId = vars.get("$field.LEADIMPORTID"); +var binMetadata = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", assignmentRowId, false, SqlUtils.getBinariesAlias(), ""); // "FILE NOT CHANGED" is set in the value process of the field to indicate that the user didn't upload a new file if (vars.get("$field.bindata") != "FILE NOT CHANGED") { - var assignmentRowId = vars.get("$field.LEADIMPORTID"); - var bindata = DocumentUtil.getBindataFromUpload(vars.get("$field.bindata")); - var filename = DocumentUtil.getFilenameFromUpload(vars.get("$field.bindata")); - - var fieldSep = ExportTemplateUtils.getFieldSeparator(vars.get("$field.FIELDSEPARATOR")); - var fieldLimit = ExportTemplateUtils.getFieldDeLimiter(vars.get("$field.FIELDDELIMITERS")); - var recordSep = ExportTemplateUtils.getSentenceSeparator(vars.get("$field.SENTENCESEPARATOR")); - + let bindata = DocumentUtil.getBindataFromUpload(vars.get("$field.bindata")); + let filename = DocumentUtil.getFilenameFromUpload(vars.get("$field.bindata")); + if(bindata != '' && filename != '') { var mimeType = DocumentUtil.getMimeTypeFromUpload(vars.get("$field.bindata")); if (mimeType == "application/vnd.ms-excel" || mimeType == "text/csv") { - - var binMetadata = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", assignmentRowId, false, SqlUtils.getBinariesAlias(), ""); - if (binMetadata.length > 0) { + if (binMetadata.length > 0) + { db.updateBinary(binMetadata[0].id, "", bindata, filename, "", "MAINDOCUMENT", SqlUtils.getBinariesAlias()); - LeadImportUtils.loadImportFile(binMetadata[0].id, fieldSep, fieldLimit, recordSep, assignmentRowId, true, true); + binId = binMetadata[0].id; } else { - var documentId = SingleBinaryUtils.insertMainDocument("LEADIMPORT", "IMPORTFILE", assignmentRowId, bindata, filename, "", SqlUtils.getBinariesAlias()); - LeadImportUtils.loadImportFile(documentId, fieldSep, fieldLimit, recordSep, assignmentRowId, false, true); + binId = SingleBinaryUtils.insertMainDocument("LEADIMPORT", "IMPORTFILE", assignmentRowId, bindata, filename, "", SqlUtils.getBinariesAlias()); } } } +} +else if (binMetadata.length > 0) +{ + binId = binMetadata[0].id; +} + +if (binId) +{ + var fieldSep = ExportTemplateUtils.getFieldSeparator(vars.get("$field.FIELDSEPARATOR")); + var fieldLimit = ExportTemplateUtils.getFieldDeLimiter(vars.get("$field.FIELDDELIMITERS")); + var recordSep = ExportTemplateUtils.getSentenceSeparator(vars.get("$field.SENTENCESEPARATOR")); - neon.refreshAll(); + LeadImportUtils.loadImportFile(binId, fieldSep, fieldLimit, recordSep, assignmentRowId, true, true); } WorkflowSignalSender.updated(); diff --git a/entity/Observation_entity/Observation_entity.aod b/entity/Observation_entity/Observation_entity.aod index abbabad7d380f1201e926ddceb58f84ef41e68a1..d1c037dc9b942c90284c4e50fc61c64ad13b1c51 100644 --- a/entity/Observation_entity/Observation_entity.aod +++ b/entity/Observation_entity/Observation_entity.aod @@ -4,6 +4,7 @@ <title>Observation</title> <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/Observation_entity/documentation.adoc</documentation> + <title>Observation</title> <titlePlural>Observations</titlePlural> <recordContainer>db</recordContainer> <entityFields> @@ -84,6 +85,11 @@ <valueProcess>%aditoprj%/entity/Observation_entity/entityfields/priokeywords/children/containername_param/valueProcess.js</valueProcess> </entityParameter> </children> + <dependency> + <name>dependency</name> + <entityName>KeywordEntry_entity</entityName> + <fieldName>#PROVIDER</fieldName> + </dependency> </entityConsumer> <entityConsumer> <name>Ussers</name> @@ -106,6 +112,11 @@ <valueProcess>%aditoprj%/entity/Observation_entity/entityfields/objectproxyconsumer/children/entity_param/valueProcess.js</valueProcess> </entityParameter> </children> + <dependency> + <name>dependency</name> + <entityName>ObjectProxy_entity</entityName> + <fieldName>FilteredObjects</fieldName> + </dependency> </entityConsumer> <entityField> <name>TRIGGEREVENTUPDATE</name> @@ -195,6 +206,11 @@ <valueProcess>%aditoprj%/entity/Observation_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js</valueProcess> </entityParameter> </children> + <dependency> + <name>dependency</name> + <entityName>Context_entity</entityName> + <fieldName>Exclusive</fieldName> + </dependency> </entityConsumer> <entityField> <name>OBSERVATION_ID</name> @@ -228,6 +244,7 @@ <recordContainers> <dbRecordContainer> <name>db</name> + <alias>Data_alias</alias> <isPageable v="false" /> <hasDependentRecords v="true" /> <conditionProcess>%aditoprj%/entity/Observation_entity/recordcontainers/db/conditionProcess.js</conditionProcess> diff --git a/entity/Product_entity/Product_entity.aod b/entity/Product_entity/Product_entity.aod index aebfbe30a70972ae9be881e2674ed9f685d73419..efb013f5cdcba22abc918fdef8c12724361d9968 100644 --- a/entity/Product_entity/Product_entity.aod +++ b/entity/Product_entity/Product_entity.aod @@ -41,7 +41,7 @@ <entityField> <name>ADVERTISING</name> <title>Advertising material</title> - <contentType>BOOLEAN</contentType> + <contentType>TEXT</contentType> <dropDownProcess>%aditoprj%/entity/Product_entity/entityfields/advertising/dropDownProcess.js</dropDownProcess> <valueProcess>%aditoprj%/entity/Product_entity/entityfields/advertising/valueProcess.js</valueProcess> </entityField> diff --git a/neonView/LeadimportLeadFilter_view/LeadimportLeadFilter_view.aod b/neonView/LeadimportLeadFilter_view/LeadimportLeadFilter_view.aod index 12e2ebd9e98a6a97a17ce7fc6fa70d3d7e417037..619914749e604c8777dead8285f7107834d55d75 100644 --- a/neonView/LeadimportLeadFilter_view/LeadimportLeadFilter_view.aod +++ b/neonView/LeadimportLeadFilter_view/LeadimportLeadFilter_view.aod @@ -17,6 +17,7 @@ <actions> <element>LeadimportReset</element> <element>TransferData</element> + <element>ReloadTransferdData</element> </actions> <entityField>#ENTITY</entityField> <devices> diff --git a/process/Leadimport_lib/process.js b/process/Leadimport_lib/process.js index de9d13b2c7bb525960c5503b3e20eb28d9f2190d..422506bef5bea01bb6500bd075ec70a66f6b172a 100644 --- a/process/Leadimport_lib/process.js +++ b/process/Leadimport_lib/process.js @@ -154,7 +154,7 @@ LeadImportUtils.loadImportFile = function(pBinId, pFieldSep, pFieldLimit, pRecor LeadImportUtils.importData = function(pDataFields, pDataTypes, pFieldDef, pFieldValues, pImportDefID, pAttrObject, pSource, pUser, pDate) { var LeadValues = LeadImportUtils.setValues(pDataFields["LEAD"], pFieldDef, pFieldValues); // set the Lead values - + var orgid = ""; var persid = ""; var persContactId = ""; diff --git a/process/importLead_serverProcess/process.js b/process/importLead_serverProcess/process.js index 35ac42b2b31f5cd4b801573bd295413747352f42..96f94dc8f09a1f7b2b868f99015e839e65025b46 100644 --- a/process/importLead_serverProcess/process.js +++ b/process/importLead_serverProcess/process.js @@ -1,3 +1,4 @@ +import("system.question"); import("system.logging"); import("system.notification"); import("system.translate"); @@ -66,133 +67,136 @@ var posOrgName = getFieldPos(ImportFieldDef, "NAME"); var posOrginfo = getFieldPos(ImportFieldDef, "INFO"); // Data without headline -var dsanz = 1; +var dataRowIndex = 1; // set the mappings LeadImportUtils.mapping = LeadImportUtils.getMapping(importdefid); - -try +if (FieldDef.filter(function (fieldDef) { return (fieldDef[1] == "LASTNAME" || fieldDef[1] == "NAME"); }).length > 0) { - for (; dsanz < data.length; dsanz++) + try { - //iterate over the fielddefinitions and set the values - var impvalues = LeadImportUtils.addArray(data[dsanz], source); - impvalues.push(ImportDate); - - // if there is no BUILDINGNO the select it from the ADDRESS - if (noBuildingNr) + for (; dataRowIndex < data.length; dataRowIndex++) { - var pos = addressPos[0]; - var buildingNr = ""; - var address = impvalues[pos]; - - if (address != "") + //iterate over the fielddefinitions and set the values + var impvalues = LeadImportUtils.addArray(data[dataRowIndex], source); + impvalues.push(ImportDate); + + // if there is no BUILDINGNO the select it from the ADDRESS + if (noBuildingNr) { - // split ADDRESS and BUILDINGNO - var arr = address.match(/^[^0-9]+|[0-9]+.*$/g); - - //Regexp can throw an error - then the array is empty - if (arr && arr[0]) + var pos = addressPos[0]; + var buildingNr = ""; + var address = impvalues[pos]; + + if (address != "") { - impvalues[pos] = arr[0].replace(/(^\s+)|(\s+$)/g,""); - if (arr[1]) buildingNr = arr[1]; + // split ADDRESS and BUILDINGNO + var arr = address.match(/^[^0-9]+|[0-9]+.*$/g); + + //Regexp can throw an error - then the array is empty + if (arr && arr[0]) + { + impvalues[pos] = arr[0].replace(/(^\s+)|(\s+$)/g,""); + if (arr[1]) buildingNr = arr[1]; + } } + impvalues.push(buildingNr); } - impvalues.push(buildingNr); - } - // if there is no COUNTRY then COUNTRY = DE - if (noCountry) impvalues.push("DE"); + // if there is no COUNTRY then COUNTRY = DE + if (noCountry) impvalues.push("DE"); - // if a ORGNAME is declared frequently - if (posOrgName.length > 1) - { - for (posanz = 1; posanz < posOrgName.length; posanz++) - { - if (impvalues[posOrgName[posanz]] != "") - impvalues[posOrgName[0]] += "\n" + impvalues[posOrgName[posanz]]; //impvalues[ posOrgName[ posanz ]] ist das Import-Datum + // if a ORGNAME is declared frequently + if (posOrgName.length > 1) + { + for (posanz = 1; posanz < posOrgName.length; posanz++) + { + if (impvalues[posOrgName[posanz]] != "") + impvalues[posOrgName[0]] += "\n" + impvalues[posOrgName[posanz]]; //impvalues[ posOrgName[ posanz ]] ist das Import-Datum + } } - } - // if a ORGINFO is declared frequently - if (posOrginfo.length > 1) - { - for (posanz = 1; posanz < posOrginfo.length; posanz++) + // if a ORGINFO is declared frequently + if (posOrginfo.length > 1) { - if (impvalues[posOrginfo[posanz]] != "" ) - impvalues[posOrginfo[0]] += "\n" + impvalues[posOrginfo[posanz]]; + for (posanz = 1; posanz < posOrginfo.length; posanz++) + { + if (impvalues[posOrginfo[posanz]] != "" ) + impvalues[posOrginfo[0]] += "\n" + impvalues[posOrginfo[posanz]]; + } } - } - //get the position of the COUNTRY - var countrypos = getFieldPos (FieldDef, "COUNTRY")[0]; + //get the position of the COUNTRY + var countrypos = getFieldPos (FieldDef, "COUNTRY")[0]; - //check the COUNTRY - impvalues[countrypos] = LeadImportUtils.checkCountry(impvalues[countrypos]); + //check the COUNTRY + impvalues[countrypos] = LeadImportUtils.checkCountry(LeadImportUtils.getMappedOutputvalue("COUNTRY", impvalues[countrypos])); - if (!(getFieldPos(ImportFieldDef, "ISOLANGUAGE").length == 0)){ - //get the position of the ISOLANGUAGE - var isolanguepos = getFieldPos (FieldDef, "ISOLANGUAGE")[0]; + if (!(getFieldPos(ImportFieldDef, "ISOLANGUAGE").length == 0)){ + //get the position of the ISOLANGUAGE + var isolanguepos = getFieldPos (FieldDef, "ISOLANGUAGE")[0]; - //mapp and check the ISOLANGUAGE - impvalues[isolanguepos] = LeadImportUtils.getMappedOutputvalue("ISOLANGUAGE", impvalues[isolanguepos]); - impvalues[isolanguepos] = LeadImportUtils.checkISOLanguage(impvalues[isolanguepos]); - } + //mapp and check the ISOLANGUAGE + impvalues[isolanguepos] = LeadImportUtils.getMappedOutputvalue("ISOLANGUAGE", impvalues[isolanguepos]); + impvalues[isolanguepos] = LeadImportUtils.checkISOLanguage(impvalues[isolanguepos]); + } - try//import data - { - var dupCheck = LeadImportUtils.importData(DataFields, DataTypes, FieldDef, impvalues, importdefid, AttrObject, source, user, currDate); + try//import data + { + var dupCheck = LeadImportUtils.importData(DataFields, DataTypes, FieldDef, impvalues, importdefid, AttrObject, source, user, currDate); - allContactData[dupCheck[0]] = [dupCheck[1], dupCheck[2]]; //persObj, orgObj - } - catch(ex)//if error increase the errorCount and write a rhinoException into the string for the error file - { - var exeption = "Zeile " + dsanz + ": " + logging.toLogString(ex.rhinoException != undefined ? ex.rhinoException : ex, true) + "\r\n"; - exeptions = exeptions + exeption; - errorCount++; - logging.log(exeption); + allContactData[dupCheck[0]] = [dupCheck[1], dupCheck[2]]; //persObj, orgObj + } + catch(ex)//if error increase the errorCount and write a rhinoException into the string for the error file + { + var exeption = "Zeile " + dataRowIndex + ": " + logging.toLogString(ex.rhinoException != undefined ? ex.rhinoException : ex, true) + "\r\n"; + exeptions = exeptions + exeption; + errorCount++; + logging.log(exeption); + } } } -} -catch(err) -{ - errorCount++; - logging.log(err); -} + catch(err) + { + errorCount++; + logging.log(err); + } -try -{ - LeadImportUtils.scanLeadDups(allContactData);//search for duplicates -} -catch (err) -{ - logging.log(err); -} + try + { + LeadImportUtils.scanLeadDups(allContactData);//search for duplicates + } + catch (err) + { + logging.log(err); + } -var rows = eMath.subInt(dsanz, 1); -rows = eMath.subInt(rows, errorCount);//datasetcount - errors = inserts + var rows = eMath.subInt(dataRowIndex, 1); + rows = eMath.subInt(rows, errorCount);//datasetcount - errors = inserts -var updTable = "LEADIMPORT"; -var updFields =["IMPORT_DATE", "DATE_EDIT", "USER_EDIT", "STATUS"]; -var updVals = [ImportDate, currDate, user, $KeywordRegistry.importStatus$transfered()]; + var updTable = "LEADIMPORT"; + var updFields =["IMPORT_DATE", "DATE_EDIT", "USER_EDIT", "STATUS"]; + var updVals = [ImportDate, currDate, user, $KeywordRegistry.importStatus$transfered()]; -var logTable = "LEADLOG"; -var logFields =["LEADLOGID", "ROWSINSERTED", "IMPORTERRORS", "LEADIMPORT_ID", "IMPORTSOURCE", "USER_NEW", "DATE_NEW"]; -var logVals = [util.getNewUUID(), rows, errorCount, importdefid, source, user, currDate]; + var logTable = "LEADLOG"; + var logFields =["LEADLOGID", "ROWSINSERTED", "IMPORTERRORS", "LEADIMPORT_ID", "IMPORTSOURCE", "USER_NEW", "DATE_NEW"]; + var logVals = [util.getNewUUID(), rows, errorCount, importdefid, source, user, currDate]; -db.insertData(logTable, logFields, null, logVals); -newWhere("LEADIMPORT.LEADIMPORTID", importdefid) + db.insertData(logTable, logFields, null, logVals); + newWhere("LEADIMPORT.LEADIMPORTID", importdefid) .updateData(true, updTable, updFields, null, updVals); -newWhere("LEADTEMP.ROW_ID", importdefid) + newWhere("LEADTEMP.ROW_ID", importdefid) .deleteData(true, "LEADTEMP");//delete existing temp data -if(exeptions != "")//insert error document - db.insertBinary("LEADLOG", "ERRORLOG", logVals[0], - "", util.encodeBase64String(exeptions, "UTF-8"), "Error-Log " + source + " " + datetime.toDate(currDate, "dd.MM.yyyy HH:mm") , "", "", SqlUtils.getBinariesAlias()); + if(exeptions != "")//insert error document + db.insertBinary("LEADLOG", "ERRORLOG", logVals[0], + "", util.encodeBase64String(exeptions, "UTF-8"), "Error-Log " + source + " " + datetime.toDate(currDate, "dd.MM.yyyy HH:mm") , "", "", SqlUtils.getBinariesAlias()); -if (userId)// if there is an user - show a notification to this user when the import is complete -{ - var description = translate.withArguments("%0 leads imported, %1 errors", [rows, errorCount]); - notification.addNotification(util.getNewUUID(), null, null, null, "LeadImport_Notification", null, notification.PRIO_NORMAL, 2, notification.STATE_UNSEEN, [userId], importName, description); + if (userId)// if there is an user - show a notification to this user when the import is complete + { + var description = translate.withArguments("%0 leads imported, %1 errors", [rows, errorCount]); + var linkInfo = text.encodeMS(["Leadimport",importdefid ]) + notification.addNotification(util.getNewUUID(), linkInfo, null, null, "LeadImport_Notification", notification.PRIO_NORMAL, 2, notification.STATE_UNSEEN, [userId], importName, description, null ); + } }