Skip to content
Snippets Groups Projects
Commit 3f7d719d authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

Merge branch '1052687_LeadimportLogsDatatypeFix' into '2020.1.0'

[Projekt: Entwicklung - Neon][TicketNr.: 1052687][Leadimport - Dokument unter...

See merge request xrm/basic!199
parents 2ba82863 03a4b7e7
No related branches found
No related tags found
No related merge requests found
import("system.vars");
import("Document_lib");
DocumentUtil.downloadSelectedDocuments();
DocumentUtil.downloadSelectedDocuments(vars.get("$param.AssignmentName_param"));
......@@ -19,7 +19,8 @@ var recordSep = ExportTemplateUtils.getSentenceSeparator(vars.get("$field.SENTEN
if(bindata != '' && filename != '')
{
var mimeType = DocumentUtil.getMimeTypeFromUpload(vars.get("$field.bindata"));
if (mimeType == "application/vnd.ms-excel" || mimeType == "text/csv")
if (mimeType == "application/vnd.ms-excel" || mimeType == "text/csv"
|| mimeType == "text/plain") //ToDo: remove this one, as soon as csv's get their correct mimetype #1057287
{
var documentId = SingleBinaryUtils.insertMainDocument("LEADIMPORT", "IMPORTFILE", assignmentRowId, bindata, filename, "", SqlUtils.getBinariesAlias());
LeadImportUtils.loadImportFile(documentId, fieldSep, fieldLimit, recordSep, assignmentRowId, false, true);
......
......@@ -19,23 +19,27 @@ function DocumentUtil(){
* Utility function to download all selected documents.
* Selected documents will be checked with $sys.selectionRows
* Documents will be downloaded with neon.download
* @param {String} pAssignmentName (optional) the name of the assignment, used to modify the filename
*
*/
DocumentUtil.downloadSelectedDocuments = function() {
DocumentUtil.downloadSelectedDocuments = function(pAssignmentName) {
var alias = SqlUtils.getBinariesAlias();
if(vars.exists("$sys.selectionRows") && vars.getString("$sys.selectionRows")) {
var rows = vars.get("$sys.selectionRows");
var uids = vars.get("$sys.selection");
var binaryContents = db.getBinaryContents(uids, alias);
// check if multiplie Files are selected.
// files get packed into a zip archive before downloading
if(binaryContents.length > 1) {
var fileNames = rows.map(function(value) { return value["NAME"]; });
neon.downloadToZip(translate.text("Files") + ".zip", binaryContents, fileNames);
} else {
neon.download(binaryContents[0], rows[0]["NAME"]);
}
else if(pAssignmentName == "ERRORLOG")
neon.download(binaryContents[0], rows[0]["NAME"] + ".txt");
else
neon.download(binaryContents[0], rows[0]["NAME"]);
}
}
......
import("ExportTemplate_lib");
import("system.workflow");
import("system.project");
import("Util_lib");
......@@ -93,6 +94,10 @@ LeadImportUtils.loadImportFile = function(pBinId, pFieldSep, pFieldLimit, pRecor
var insertCols = ["IMPORTFIELDID", "FIELDNAME", "LEADIMPORT_ID", "DATE_NEW", "USER_NEW", "FIELDNUMBER"];
var insertTypes = db.getColumnTypes(insertTable, insertCols);
var insertVals = [];
var sentenceSeparator = ExportTemplateUtils.getSentenceSeparator(pRecordSep);
var fieldSeparator = ExportTemplateUtils.getFieldSeparator(pFieldSep);
var fieldDeLimiter = ExportTemplateUtils.getFieldDeLimiter(pFieldLimit);
if (pUpdate == undefined) pUpdate = false;
......@@ -102,7 +107,7 @@ 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));
var table = text.parseCSV(data.replace(/(^\s+)|(\s+$)/g,""), sentenceSeparator, fieldSeparator, fieldDeLimiter);
if (pNewFile)
{
if (pUpdate) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment