public PageReference back() {
    PageReference pgRef = new PageReference('/' + oppId);

    return pgRef;
  • 2
    ...by adding the @auraEnabled annotation on the line above the method signature?
    – Derek F
    Jan 25, 2022 at 13:00
  • @AuraEnabled public static string back(){ '/'+ oppId return; }
    – user110347
    Jan 25, 2022 at 13:03
  • I tried like this
    – user110347
    Jan 25, 2022 at 13:04
  • 2
    Welcome to Salesforce Stack Exchange (SFSE)! Instead of adding them as comments, please edit your question to add these and any future additional things that you have tried (please don't edit the original code in the question - that can cause confusion for future readers). It makes it easier for people trying to help you to see all the information in the question. Some people add Update at the bottom of their question, and then add new information there.
    – Moonpie
    Jan 25, 2022 at 13:07

2 Answers 2


Navigation in Aura and LWC is done with force:navigateToUrl and NavigationMixin. There's usually no need to get Apex involved at all.


You can try as @sfdcfox suggested using either methods, or in your JS can also try to redirect the user using window.open(location to redirect);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .