Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto detect import externalId field #178

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 1.23

- Format relations as expected in import process [feature 26](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/26) (contribution by [Olivier Dufour](https://github.com/dufoli))
- Ability to choose header theme [feature 294](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/294)
- Add query template customization in Option page [feature 349](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/349)
- Display correct banner when session is expired instead of "Generate new token" [feature 305](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/305)
Expand Down
35 changes: 34 additions & 1 deletion addon/data-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Model {
this.importTableResult = null;
this.updateResult(null);

this.describeInfo = new DescribeInfo(this.spinFor.bind(this), () => { });
this.describeInfo = new DescribeInfo(this.spinFor.bind(this), () => { this.refreshColumn()});
this.spinFor(sfConn.soap(sfConn.wsdl(apiVersion, "Partner"), "getUserInfo", {}).then(res => {
this.userInfo = res.userFullName + " / " + res.userName + " / " + res.organizationName;
}));
Expand Down Expand Up @@ -187,6 +187,8 @@ class Model {
this.importAction = "update";
this.importActionName = "Update";
}
this.refreshColumn();
this.updateResult(this.importData.importTable);
}

getDataFromJson(json) {
Expand Down Expand Up @@ -602,6 +604,36 @@ class Model {
return hasId ? true : false;
}

guessColumn (col) {
if (!col) {
return 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()));
if (externalIdColumn) {
return externalIdColumn;
}
}
return col.trim();
}

refreshColumn() {
if (!this.importData.importTable) {
return;
}
if (!this.importData.importTable.header) {
return;
}
this.importData.importTable.header = this.importData.importTable.header.map(c => {
if (!c) {
return c;
}
c.columnValue = this.guessColumn(c.columnOriginalValue);
return c;
});

}
makeColumn(column, index) {
let self = this;
let xmlName = /^[a-zA-Z_][a-zA-Z0-9_]*$/; // A (subset of a) valid XML name
Expand Down Expand Up @@ -912,6 +944,7 @@ class App extends React.Component {
onImportTypeChange(e) {
let {model} = this.props;
model.importType = e.target.value;
model.refreshColumn();
model.didUpdate();
}
onDataFormatChange(e) {
Expand Down