You need to sign in to do that
Don't have an account?
Akshay Pai
URL.getSalesforceBaseUrl() function is not working as expected in Lightening experience
Hi All,
I have a Custom button which uses Visualforce page with custom controller. Custom controller's save function does some calculations and redirects to Origin record page where my custon button is placed.
This is working as expected in Salesforce classic. But in Lightening experience the return page is opening in new tab and showing origin page in classic version. I want to redirect the page to my Origin record page where my custon button is placed in Lightening experience and in the same tab.
Can anyone please help me to achieve this? Thanks in advace.
I have a Custom button which uses Visualforce page with custom controller. Custom controller's save function does some calculations and redirects to Origin record page where my custon button is placed.
VF PAGE: <apex:page standardController="ABC__c" extensions="CustomController" action="{!save}"> </apex:page>
Custom controller: public class CustomController { // Constructor and other intializations public PageReference save() { try{ // performing some calculations //return reference. String returnUrl = URL.getSalesforceBaseUrl().toExternalForm() +'/' + EncodingUtil.URLENCODE(ApexPages.currentPage().getParameters().get(retURL),'UTF-8'); return new Pagereference(returnUrl); }catch(System.DMLException e){ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,e.getDmlMessage(0))); return null; } } }
This is working as expected in Salesforce classic. But in Lightening experience the return page is opening in new tab and showing origin page in classic version. I want to redirect the page to my Origin record page where my custon button is placed in Lightening experience and in the same tab.
Can anyone please help me to achieve this? Thanks in advace.
So try to use navigate to URL event, it works for you. I hope your project running in Lightning Environment.