I had to create a custom component that is used to create a new record for sobject Account.
To achieve this, I'm following the pattern from Trailhead https://trailhead.salesforce.com/en/projects/workshop-override-standard-action/steps/override_4
Which is also used in Andrew Fawcett's blog https://andyinthecloud.com/2017/05/30/overriding-standard-actions-with-lightning-components/
For reproduction, you can take the source code from there with minimal mods. If necessary, plz ask and I will provide my code here, but its based on that.
After the account is created the custom modal closes and it will be redirected to the created account as I get back the
Id from Apex. This is fine, if the New button was pressed from a ListView.
BUT NOT when we create an new account from an existing(!) Opportunity using the Account-Lookup on the Oppy-record-detail (see photo below). There is the "+ New Account" invoking the same custom LC (as expected), but after filling it up with required fields and press on Save should go back to our Opportunity from which context it has been started.
But unfortunately it gets redirected to the new record. It is the same as when we go to Account List View and press New it will redirect to the component and then to the new record.
Obviously it's necessary to go back to the Opportunity which the User was about to create and which has been interrupted by the popup and NOT to the new account.
Is there a possible way to know the path that we came from to simply go back to it in case the component have been executed from an sobject's record? All Fields which has been filled should be populated exactly as it was before we left - btw. this is exactly what the nativ new-popup does: it returns smoothly back to the Opportunity which we were about to create with NO loss of any previously populated fields.