[SalesForce] Redirect to perticular record related of a record in Lightning

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

/02i?rlid=RelatedAssetList&id=001800000....

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?

Best Answer

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");
  relatedListEvent.setParams({
      "relatedListId": "Cases",
      "parentRecordId": component.get("v.recordId")
  });
  relatedListEvent.fire();
}
Related Topic