We have a visualforce page that is a form. This form selects the RecordType, and write some text fields. After that, the apex controller uses URL Hacking to pre-populate the fields in a standard page, but the fields can't be populated on the standard page in lightning.

We can't use quick actions or buttons to recreate it in lightning because is the user is who select or write some of the values that we need to pre-populate in the standard page.

Also we tried to embed the visualforce in a lightning component.

Is it possible to send the values from apex controller to the lightning standard page without reprogramming from scratch?

The apex code is something like:

final static String initUrl = '/' + Object__c.sObjectType.getDescribe().getKeyPrefix() + '/e?';
    final static String endUrl = '&retURL=' + Object__c.sObjectType.getDescribe().getKeyPrefix() + '/o&nooverride=1';
    public Pagereference next(){
            Pagereference aPage = null;

            String urlBase = initUrl + 'RecordType=' + recordTypeId +

Do some comprobations to concatenate the ID of the field with the value

urlBase = urlBase + '&00N5800000CLqAF=1';
urlBase += endUrl;

            aPage = new Pagereference(urlBase);
            return aPage;



  • Have you overrides the new button in Classic with Visualforce page? Nov 29 '19 at 11:55
  • Yes, the button in classic is the New Button overrided with the Visualforce page.
    – roquer
    Nov 29 '19 at 12:29
  • Why you don't simply override the new button in lightning too with your existing visualforce page? Nov 29 '19 at 12:33
  • I tried to override the button in lightning with the existing visualforce, but I have the same problem. The visualforce button calls an Apex method that creates a PageReference object with a formated URL and setRedirect that page. It redirects to the standard insert page in lightning, so the URL sent it's missing and no field is pre-populated in the page.
    – roquer
    Dec 2 '19 at 10:05
  • Can you add the code as well in your question? Dec 2 '19 at 10:06

After looking your code,You are using Pagereference to navigate users with defining the field values using URL Hack. That is the reason it is not working in Lightning.

You can migrate the functionality to Lightning component and use force:createRecord to navigate users to create record page with pre-defined values for the field.

A sample example:-

var createAcountContactEvent = $A.get("e.force:createRecord");
    "entityApiName": "Contact",
    "defaultFieldValues": {
        'Phone' : '415-240-6590',
        'AccountId' : '001xxxxxxxxxxxxxxx'
  • Is there a possibility if I embed the Visualforce on a lightning component and get the values of the Visualforce or redirect to the classic page in lightning to get the values pre-populated without migrate the code to lightning from scratch?
    – roquer
    Dec 2 '19 at 12:20

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.