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 17, 2023
1 parent 4636447 commit a87d6f7
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 @@ -513,7 +513,7 @@ class Model {
let xmlName = /^[a-zA-Z_][a-zA-Z0-9_]*$/; // A (subset of a) valid XML name
let columnVm = {
columnIndex: index,
columnValue: column.trim(),
columnValue: this.guessColumn(column),
columnOriginalValue: column,
columnIgnore() { return columnVm.columnValue.startsWith("_"); },
columnSkip() {
Expand Down Expand Up @@ -551,6 +551,14 @@ class Model {
columnUnknownField() {
return columnVm.columnError() === "Error: Unknown field";

},
guessColumn (col) {
let columnName = col.split(".");
if (columnName.length == 2) {
let externalIdColumn = self.columnList().find(s => s.toLowerCase().startsWith(columnName[0].toLowerCase()) && s.toLowerCase().endsWith(columnName[1].toLowerCase()));
return externalIdColumn;
}
return col.trim();
}
};
return columnVm;
Expand Down

0 comments on commit a87d6f7

Please sign in to comment.