diff --git a/CHANGES.md b/CHANGES.md index 8368dca6..43ff7a7d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ ## Version 1.22 +- Allow users to define REST callout headers on showAllData page. The need is to prevent the auto assignation of Accounts, Cases and Leads. [feature 198](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/198) (issue by [SfdxDieter](https://github.com/SfdxDieter) - Fix flow scrollability] checkbox on non dev environments [issue 258](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/258) (by [Samuel Krissi](https://github.com/samuelkrissi)) - Fix 'Record Type not displayed' in popup [issue 255](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/255) - Add "Options" page to manage local storage variables directly from the UX. Allow to reposition the popup button [feature 145](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/145) (contribution by [Pietro Martino](https://github.com/pietromartino)) diff --git a/addon/inspect.js b/addon/inspect.js index e4445537..9dbcaed2 100644 --- a/addon/inspect.js +++ b/addon/inspect.js @@ -33,6 +33,7 @@ class Model { this.detailsFilter = ""; this.detailsBox = null; this.editMode = null; // null (when not editing), "update", "delete" (for confirming) or "create" + this.headerCallout = localStorage.getItem("createUpdateRestCalloutHeaders") ? JSON.parse(localStorage.getItem("createUpdateRestCalloutHeaders")) : "{}"; this.hasEntityParticles = false; this.objectActionsOpen = false; this.objectSetupLinks = null; @@ -148,7 +149,7 @@ class Model { let recordUrl = this.objectData.urls.rowTemplate.replace("{ID}", this.recordData.Id); this.spinFor( "saving record", - sfConn.rest(recordUrl, {method: "PATCH", body: record}).then(() => { + sfConn.rest(recordUrl, {method: "PATCH", body: record, headers: this.headerCallout}).then(() => { this.endEdit(); this.clearRecordData(); this.setRecordData(sfConn.rest(recordUrl)); @@ -175,7 +176,7 @@ class Model { let recordUrl = this.objectData.urls.sobject; this.spinFor( "creating record", - sfConn.rest(recordUrl, {method: "POST", body: record}).then(result => { + sfConn.rest(recordUrl, {method: "POST", body: record, headers: this.headerCallout}).then(result => { this.endEdit(); let args = new URLSearchParams(); args.set("host", this.sfHost); diff --git a/addon/options.js b/addon/options.js index a6998f9e..dcfba0b8 100644 --- a/addon/options.js +++ b/addon/options.js @@ -86,7 +86,8 @@ class OptionsTabSelector extends React.Component { title: "API", content: [ {option: APIVersionOption, key: 1}, - {option: APIKeyOption, key: 2} + {option: APIKeyOption, key: 2}, + {option: RestHeaderOption, key: 3} ] }, { @@ -158,7 +159,6 @@ class ArrowButtonOption extends React.Component { onChangeArrowOrientation(e) { let orientation = e.target.value; this.setState({arrowButtonOrientation: orientation}); - console.log("[SFInspector] Setting Arrow Orientation: ", orientation); localStorage.setItem("popupArrowOrientation", orientation); window.location.reload(); } @@ -229,6 +229,34 @@ class APIVersionOption extends React.Component { } } +class RestHeaderOption extends React.Component { + + constructor(props) { + super(props); + this.onChangeRestHeader = this.onChangeRestHeader.bind(this); + this.state = {restHeader: localStorage.getItem("createUpdateRestCalloutHeaders") ? localStorage.getItem("createUpdateRestCalloutHeaders") : ""}; + } + + onChangeRestHeader(e) { + let restHeader = e.target.value; + this.setState({restHeader}); + localStorage.setItem("createUpdateRestCalloutHeaders", restHeader); + } + + render() { + return h("div", {className: "slds-grid slds-border_bottom slds-p-horizontal_small slds-p-vertical_xx-small"}, + h("div", {className: "slds-col slds-size_4-of-12 text-align-middle"}, + h("span", {}, "Rest Header") + ), + h("div", {className: "slds-col slds-size_2-of-12 slds-form-element slds-grid slds-grid_align-end slds-grid_vertical-align-center slds-gutters_small"}, + h("div", {className: "slds-form-element__control slds-col slds-size_6-of-12"}, + h("input", {type: "text", id: "restHeaderInput", className: "slds-input", placeholder: "Rest Header", value: this.state.restHeader, onChange: this.onChangeRestHeader}), + ) + ) + ); + } +} + class FlowScrollabilityOption extends React.Component { constructor(props) { diff --git a/docs/how-to.md b/docs/how-to.md index 73db6bbd..34f0bfbc 100644 --- a/docs/how-to.md +++ b/docs/how-to.md @@ -147,6 +147,16 @@ You can enable this view for the Shortcut search by creating a new localVariable Then when you click on a PermissionSet / PermissionSetGroups search result, you'll be redirected to the summary. +## Customize Create / Update rest callout headers (to prevent execution of auto assignment rules for Accounts, Cases, or Leads) + +[Assignment Rule Header](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers_autoassign.htm) + +From the popup, click on "Options" button and select the API tab. + +image + +If you want to prevent auto assignment rules, set the `createUpdateRestCalloutHeaders` property to `{"Sforce-Auto-Assign" : false}` + ## Update API Version Since the plugin's api version is only updated when all productions have been updated to the new release, you may want to use the latest version during preview windows.