From afa2fdb235d16eb7ce3b0985afb656d084bafbf6 Mon Sep 17 00:00:00 2001 From: olivier Dufour Date: Wed, 18 Oct 2023 20:00:18 +0200 Subject: [PATCH] Automatically request SObject type when data export from an SObject record (#45) --- CHANGES.md | 1 + addon/inspect.js | 4 ++-- addon/popup.js | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fa478e354..e732501d5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,7 @@ - Update pop-up release note link to github pages - Detect SObject on listview page [feature 121](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/121) (idea by [Mehdi Cherfaoui](https://github.com/mehdisfdc)) - Automate test setup manual step of contact to multiple accounts [Aidan Majewski](https://github.com/aimaj) +- Automatically request SObject type when data export from an SObject record [feature 45](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/45) ## Version 1.19 diff --git a/addon/inspect.js b/addon/inspect.js index 6ace027bb..705350866 100644 --- a/addon/inspect.js +++ b/addon/inspect.js @@ -235,9 +235,9 @@ class Model { if (!objectName) { return undefined; } - let query = "select Id from " + objectName; + let query = "SELECT Id FROM " + objectName; if (this.recordData && this.recordData.Id) { - query += " where Id = '" + this.recordData.Id + "'"; + query += " WHERE Id = '" + this.recordData.Id + "'"; } return this.dataExportUrl(query); } diff --git a/addon/popup.js b/addon/popup.js index a14ebec80..cc417dbc3 100644 --- a/addon/popup.js +++ b/addon/popup.js @@ -152,6 +152,19 @@ class App extends React.PureComponent { addonVersion } = this.props; let {isInSetup, contextUrl, apiVersionInput} = this.state; + let recordId = getRecordId(contextUrl); + let path = getSfPathFromUrl(contextUrl); + let sobject = getSobject(contextUrl); + let exportArg = new URLSearchParams(); + exportArg.set("host", sfHost); + if (!sobject) { + let query = "SELECT Id FROM " + sobject; + if (!recordId) { + query += " WHERE Id = '" + recordId + "'"; + } + exportArg.set("query", query); + } + let clientId = localStorage.getItem(sfHost + "_clientId"); let orgInstance = this.getOrgInstance(sfHost); let hostArg = new URLSearchParams(); @@ -182,7 +195,7 @@ class App extends React.PureComponent { h(AllDataBox, {ref: "showAllDataBox", sfHost, showDetailsSupported: !inLightning && !inInspector, linkTarget, contextUrl}), h("div", {className: "slds-p-vertical_x-small slds-p-horizontal_x-small slds-border_bottom"}, h("div", {className: "slds-m-bottom_xx-small"}, - h("a", {ref: "dataExportBtn", href: "data-export.html?" + hostArg, target: linkTarget, className: "page-button slds-button slds-button_neutral"}, h("span", {}, "Data ", h("u", {}, "E"), "xport")) + h("a", {ref: "dataExportBtn", href: "data-export.html?" + exportArg, target: linkTarget, className: "page-button slds-button slds-button_neutral"}, h("span", {}, "Data ", h("u", {}, "E"), "xport")) ), h("div", {className: "slds-m-bottom_xx-small"}, h("a", {ref: "dataImportBtn", href: "data-import.html?" + hostArg, target: linkTarget, className: "page-button slds-button slds-button_neutral"}, h("span", {}, "Data ", h("u", {}, "I"), "mport"))