function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sreenath reddy 21sreenath reddy 21 

url in visualforce pages

Hi all,
my requirement is pass data from account to opportunity. I am using visualforce pages.
1. url = '/006/e?ent=Opportunity&nooverride=1&+Amount='AnnualRevenue;
Above url working file for classic.

2.url = '/lightning/o/Opportunity/new?recordTypeId='+rtype+'nooverride=true&defaultFieldValues=Amount='+AnnualRevenue;

It is also working fine and giving expected results.

But my problem is when comment 2nd url, first one only succesfully in classic. In lightning it is not opening.

When comment 1st url, run second url it is always go to lightning.
I want when user is in classic it opens classic page, when user is in lightning it opens lightning page. 

Thanks.
 
ShivankurShivankur (Salesforce Developers) 
Hi Sreenath,

Please note this behavior is expected one since the URL and redirection pattern in Salesforce classic and lightning experience is altogetherly different.

In your scenaior you could check if the user is classic or lightning experience and based on which you could redirect the user to correct URL which would work for them.

Check with this helpful link to understand and identify the experience in which the user is:
http://bobbuzzard.blogspot.com/2015/11/context-is-everything.html

Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.
Suraj Tripathi 47Suraj Tripathi 47
Hi Sreenath,
Greetings!

Please use ApexPages Class to get the URL of the current page.
apexpages.currentpage().geturl() this will return the current URL of the page.

If you find your Solution then mark this as the best answer. 

Thank you!

Regards,
Suraj Tripathi