diff --git a/entity/Leadimport_entity/Leadimport_entity.aod b/entity/Leadimport_entity/Leadimport_entity.aod index f0069f155b74c7e290763591afd1fd2d9b6c3842..581974e1ddbb8e96b477f569df071eeb2d34c28b 100644 --- a/entity/Leadimport_entity/Leadimport_entity.aod +++ b/entity/Leadimport_entity/Leadimport_entity.aod @@ -53,7 +53,7 @@ <name>bindata</name> <title>File</title> <contentType>FILE</contentType> - <mandatory v="true" /> + <valueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/bindata/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/bindata/displayValueProcess.js</displayValueProcess> </entityField> <entityField> diff --git a/entity/Leadimport_entity/entityfields/bindata/valueProcess.js b/entity/Leadimport_entity/entityfields/bindata/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..8d94fcc642fb991e7d601c072f0d8b57dfd02c6e --- /dev/null +++ b/entity/Leadimport_entity/entityfields/bindata/valueProcess.js @@ -0,0 +1,23 @@ +import("system.neon"); +import("Sql_lib"); +import("system.result"); +import("system.vars"); +import("system.db"); +import("Document_lib"); + +if (vars.get("$sys.recordstate") && vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW) +{ + var binMetadatas = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", vars.get("$field.LEADIMPORTID"), false, SqlUtils.getBinariesAlias(), ""); + + if (binMetadatas.length > 0) + { + // preset with data from db. This is mostly to allow just editing the other fields without uploading a file (because this field is mandatory) + var resultValue = binMetadatas[0].filename; + resultValue += ";" + db.getBinaryContent(binMetadatas[0].id, SqlUtils.getBinariesAlias()); + resultValue += ";" + binMetadatas[0].mimetype; + + result.string(resultValue); + } else { + result.string("FILE MISSING"); + } +} \ No newline at end of file diff --git a/process/Leadimport_lib/process.js b/process/Leadimport_lib/process.js index 403521f38dd8793176a7c3c7df96a42a461567d4..61bee38336630cc44d40fde78ed32166d5035a9e 100644 --- a/process/Leadimport_lib/process.js +++ b/process/Leadimport_lib/process.js @@ -101,7 +101,6 @@ LeadImportUtils.loadImportFile = function(pBinId, pFieldSep, pFieldLimit, pRecor var data = db.getBinaryContent(pBinId, SqlUtils.getBinariesAlias()); data = util.decodeBase64String(data, "UTF-8"); var table = text.parseCSV( data.replace(/(^\s+)|(\s+$)/g,""), pRecordSep, pFieldSep, pFieldLimit.charAt(0)); - logging.log(JSON.stringify([table], null, "\t")) if(pNewFile != "true") { if(pUpdate) { @@ -327,6 +326,7 @@ LeadImportUtils.getImportFieldDef = function(pID) for (let i = 0; i < ImportFieldDef.length; i++) { FieldDef[i] = new Array (ImportFieldDef[i][0], ImportFieldDef[i][1]) + // TODO: this could be done using the Keyword Attributes instead of doing cracy substinging etc... if(ImportFieldDef[i][1].substr(0, 9) == "ATTRIBUTE")//ATTRIBUTES are defined like ATTRIBUTE_Loyalty { var attrName = ImportFieldDef[i][1].substr(10);// so cut the first 10 characters off to get the ATTRIBUTENAME "Loyalty"