We have a visualforce page on opportunity which is redirecting the URL as below


i.e redirect to Asset related list of an accountId mentioned. This is not working in lightning experience as it is an URL hack.

Is there any alternative approach to redirect to related list of account from the same visualforce page without rewriting it in Lightning?

  • 2
    not in accordance with best practices, you will want to use lightning events for the redirection
    – glls
    Oct 15, 2018 at 19:09
  • Like +1@glls suggested i would suggest leveraging something like lighting quick actions to rewrite and leverage lightning navigation events! Oct 15, 2018 at 19:26

2 Answers 2


Is there any alternative approach to redirect to related list of account from the same visualforce page without rewriting it in Lightning?

If there is one thing to retain from all the documentation and blogs on the subject, it is the following while you are at it.

URL hacks were never officially supported

that being said, you will want to actually migrate from unsuported URL hacks to an actual lightning component that leverages Lightning Navigation Events.

Based on what you have posted, the code itself should be pretty trivial and easy to implement in a lightning component. (redirect to a related list page of the current record)

you might want to check the documentation for lightning navigation events:

you will need to use a recordId attribute (for the current record in context)

and in your component, you can easily create a hyperlink or button that references the page where your related list is.

btw, there is a native lightning event to Navigate To Related List towards a related list:

gotoRelatedList : function (component, event, helper) {
  var relatedListEvent = $A.get("e.force:navigateToRelatedList");
      "relatedListId": "Cases",
      "parentRecordId": component.get("v.recordId")

If you want to stick to the Visualforce page, You still have an option apart from URL hack. i.e using:-

sforce.one.navigateToRelatedList(relatedListId, parentRecordId)

Navigates to a related list for the parentRecordId. For example, to display a related list for an Account object, the parentRecordId is Account.Id. relatedListId is the API name or ID of the related list to display.

Sample Code:-

<apex:page >
    <script type="text/javascript">
        var myUserContext = "{!$User.UIThemeDisplayed}";
        function naviToRelatedList(recordId) {

            if (myUserContext == 'Theme4t' || myUserContext == 'Theme4d') {
                sforce.one.navigateToRelatedList('Contacts', recordId);
            } else {
                window.location.href = '/' + recordId;

            return false;

Note:- sforce.one.navigateToRelatedList it works only in lightning and mobile app, so for the classic, you have to handle separately.


Theme4d -Lightning Experience
Theme3- Classic
Theme4t- Mobile App

You have to also call the method naviToRelatedList(recordId) in your VF page onclick or oncomplete or whenever you want.

Reference:- Navigation with the sforce.one Object

You must log in to answer this question.

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