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.

enter image description here

enter image description here

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.

enter image description here


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.

  • Is <aura:attribute name="recordId" type="Id" /> holding the opportunity record Id when created from the LookUp? – codeyinthecloud Jun 11 '18 at 14:41
  • Based on the Trailhead you posted, you use the navigateToObjectHome at the end of the save. That's why you see the Account related List and not the Opportunity modal. – Christian Croce Nov 8 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.