I am trying out to figure out if I missing some configuration or if there is a workaround for this requirement to make it work as expected.

I have an email triggered from my apex controller which uses VF email template. In the email template I have the dynamic lightning URL for the record view. The logic works fine, but the issue is the URL in the email onclick redirects to login page -->on login it lands on Home page rather than redirecting to the record view. If the user is already logged in and I click the URL from email it works as expected i.e navigates to the record view.

Here is the URL format I have in my VF email template:


Any thoughts or ideas would be greatly appreciated.


1 Answer 1


You shouldn't need to do that; simply link to https://mydomain.my.salesforce.com/{!relatedTo.Id}. This link will work in both Classic and Lightning. For a user with Lightning enabled, alohaRedirect will take care of directing Lightning to the correct record, while a user in Classic will go directly to the Classic detail page.

  • Hi sfdcfox, Unfortuntely even though I was sys admin and and was lightning enabled, using the mydomain.my.salesforce.com{!relatedTo.Id} redirected me to classic page. Commented Mar 20, 2018 at 17:23
  • My apologies for not being clear.Works fine on desktop with mydomain.my.salesforce.com/{!relatedTo.id}. but in IOS it redirects to classic page Commented Mar 20, 2018 at 17:30

You must log in to answer this question.

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