Skip to content

Commit

Permalink
auto detect import externalId field
Browse files Browse the repository at this point in the history
  • Loading branch information
dufoli committed Oct 18, 2023
1 parent 172cee2 commit ad52834
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion addon/data-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,20 @@ class Model {
return hasId ? true : false;
}

guessColumn (col) {
let columnName = col.split(".");
if (columnName.length == 2) {
let externalIdColumn = this.columnList().find(s => s.toLowerCase().startsWith(columnName[0].toLowerCase()) && s.toLowerCase().endsWith(columnName[1].toLowerCase()));
return externalIdColumn;
}
return col.trim();
}
makeColumn(column, index) {
let self = this;
let xmlName = /^[a-zA-Z_][a-zA-Z0-9_]*$/; // A (subset of a) valid XML name
let columnVm = {
columnIndex: index,
columnValue: column.trim(),
columnValue: self.guessColumn(column),
columnOriginalValue: column,
columnIgnore() { return columnVm.columnValue.startsWith("_"); },
columnSkip() {
Expand Down

0 comments on commit ad52834

Please sign in to comment.