2

I have old apex controller which has constructor implemented as follows:

public class RetrieveRecordId{
   Id recordId;
   public RetrieveRecordId(ApexPages.StandardController controller) {
     recordId = controller.getId();
   }
}

Now this was working fine in salesforce classic, but when org was switched to lightning ApexPages.StandardController does not get the recordId when a url na15.salesforce.com/apex/RetrieveRecordIdPage?id=a0o58000000a8qJAaQ .

I know lightning URL don't know what parameters are being passed. Is there any workaround to get params with existing apex code without changing to aura enabled controllers.

2 Answers 2

0

It is not an issue about Visualforce not able to passing the record Id. It is about you can't open a Visualforce page by just putting the url in the location bar in lightning experience.

In short, lightning experience is a single page app, so every visualforce page is treated as an iframed component, instead of a separate page. So you can't simply put the url in the location bar to open the page.

Instead, you need to type the below javascript in your console to navigate to your visualforce page:

$A.get("e.force:navigateToURL").setParams(
    {"url": "/apex/pageName"}).fire();

For more information, refer to this trailhead: https://trailhead.salesforce.com/lex_dev_visualforce/lex_dev_visualforce_process

1
  • Eric @Lance Shi That's true. Figured out that it was not a issue with VF page but the way we were navigating. Jan 23, 2017 at 23:37
1

This works just find when displayed inline with the record and with displayed using a Lightning action:

Page

<apex:page standardController="Account" extensions="my_Controller" showHeader="false" sidebar="false">

{!testId}

</apex:page>

Controller

public class my_Controller {

    public Id testId {get;set;}

    public my_Controller(ApexPages.standardController con){
        testId = con.getId();
    }
}

Lightning Action was to simply show a custom visualforce page.

Give it a try and see. Maybe something else going on and without your markup it is hard to say

enter image description here

How are you causing the VF page to load?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.