You need to sign in to do that
Don't have an account?
Page reference makes VF page hang on redirect to detail page.
Hi! I'm returning the following page reference in a Save method in a controller extension for a VF page:
pageReference('/lightning/r/Account/' + [Account's Id] + '/view')
which works fine in Standard navigation mode, redirecting to the detail page, but in Console mode it just makes the VF page hang, needing to be manually closed (although the record is still saved).
Can someone please assist?
Thanks!
pageReference('/lightning/r/Account/' + [Account's Id] + '/view')
which works fine in Standard navigation mode, redirecting to the detail page, but in Console mode it just makes the VF page hang, needing to be manually closed (although the record is still saved).
Can someone please assist?
Thanks!
Apex Code Development
Hi Pedro, Apply these steps.
Here are a few suggestions for returning a page reference in a controller extension for a Visualforce page that works in both standard and console navigation modes:
Use the StandardController and redirect to the standard detail page:
ApexPages.StandardController stdController = new ApexPages.StandardController(record);
return stdController.view();
Use the Lightning component NavigationMixin to navigate:
NavigationMixin navigation = new NavigationMixin();
navigation.navigateToSObject(recordId);
return null;
Check the user's navigation mode and return different page references:
if(UserInterfaceThemeDisplay.isConsoleUser()) {
return new PageReference('/lightning/r/Account/' + recordId + '/view');
} else {
return new ApexPages.StandardController(record).view();
}
Use PageReference methods like setRedirect(true) to avoid hanging:
PageReference pageRef = new PageReference('/lightning/r/Account/' + recordId + '/view');
pageRef.setRedirect(true);
return pageRef;
The key is to avoid returning a Visualforce page reference directly in console mode. Hope this helps troubleshoot the issue! Let me know if any of these suggestions work or if you have any other questions.
All Answers
Can you please share the logic which you have used in save method?
Check for any errors in browser's developer console (F12). JavaScript errors could interfere with the proper functioning of your page.
public PageReference Save() { this.ValidationMsg1 = ''; this.ValidationMsg2 = ''; this.ValidationMsg3 = ''; //this.ManualUpdMsg = ''; this.ShowMsg = false; this.ShowMsg1 = false; this.ShowMsg2 = false; this.ShowMsg3 = false; if (this.addressChoice == 'Primary'){ SavePrimary(); } if (this.addressChoice == 'Alternative'){ SaveAlternative(); } if (this.ShowMsg) { String url1 = Apexpages.currentPage().getUrl(); pageReference ref1 = new pageReference(url1); return ref1; } else { update this.acc; pageReference pgeRef; pgeRef = new pageReference('/lightning/r/Account/' + this.acc.Id + '/view'); pgeRef.setRedirect(true); return pgeRef; } }Hi Pedro, Apply these steps.
Here are a few suggestions for returning a page reference in a controller extension for a Visualforce page that works in both standard and console navigation modes:
Use the StandardController and redirect to the standard detail page:
ApexPages.StandardController stdController = new ApexPages.StandardController(record);
return stdController.view();
Use the Lightning component NavigationMixin to navigate:
NavigationMixin navigation = new NavigationMixin();
navigation.navigateToSObject(recordId);
return null;
Check the user's navigation mode and return different page references:
if(UserInterfaceThemeDisplay.isConsoleUser()) {
return new PageReference('/lightning/r/Account/' + recordId + '/view');
} else {
return new ApexPages.StandardController(record).view();
}
Use PageReference methods like setRedirect(true) to avoid hanging:
PageReference pageRef = new PageReference('/lightning/r/Account/' + recordId + '/view');
pageRef.setRedirect(true);
return pageRef;
The key is to avoid returning a Visualforce page reference directly in console mode. Hope this helps troubleshoot the issue! Let me know if any of these suggestions work or if you have any other questions.