1

In Classic: There is a New button on the VF page. On click of this button default new record create a page of the custom object gets open. On saving of the record, the page gets redirected to the VF page(On which new button was clicked). enter image description here

Now we converted this VF page to lightning experience and we are facing a problem following problem. On click of New button on VF page, a pop-up appears to create a new record (custom object) but in the background, VF page redirects to the blank page. So when we save this record, we are not redirected to the previous VF page.

New Button: enter image description here Popup: enter image description here

Code used in contoller for returning url in classic:

Schema.DescribeSObjectResult ppConfigObj = Priority_Points_Settings__c.sObjectType.getDescribe();
String url = ApexPages.currentPage().getUrl();
PageReference pageRef = new PageReference('/'+ppConfigObj.getKeyPrefix()+'/e?retURL='+url);
return pageRef;

On VF page, above function is called:

<apex:commandButton value="New" id="newButtonConfig" action="{!createNewPriorityPointConfig}"/>

Please suggest a solution to solve this issue.

2 Answers 2

1

In your code, you are setting the page reference as follows:

PageReference pageRef = new PageReference('/'+ppConfigObj.getKeyPrefix()+'/e?retURL='+url);

In particular, you are calling a method ppConfigObj.getKeyPrefix() that looks as though you're getting the object name or something from a map. It's not exactly clear what it is since you don't show that part of your code. For all I know it could be the full path to the page like: /Apex/thisVisualForcePageName.

I think what you want to be doing is one of two things. Either converting that button to an Action (the action would work the same in Lightning) or convert the link to the proper format that Lightning expects it to have; one that includes the Object Name. When constructing the button link, I think you probably want to do something like the following:

{!URLFOR( $Action.Case.NewCase, $ObjectType.Case )} 

See Constructing Effective Custom URL Buttons and Links in the Salesforce Documentation for more on this subject with additional details and considerations that might apply to your situation.

3
  • In classic, on click of the new button on the VF page, the default new create record page of the custom object gets open. On saving the record, the page is redirecting back to the VF page(on which new button was clicked). For returning URL, we used the following code: PageReference pageRef = new PageReference('/'+ppConfigObj.getKeyPrefix()+'/e?retURL='+url); where the ppConfigObj.getKeyPrefix() gets the custom object id prefix.
    – Ajinkyasd
    Dec 27, 2018 at 5:35
  • Lightning will be expecting the Object name, not the object Id prefix. That may be something you'll want to change in your map code. If you look at all of the lightning component methods, they reference the object name. That prefix will change from org to org for custom objects of the same name.
    – crmprogdev
    Dec 27, 2018 at 5:54
  • I am using the above logic to open the create new record create page. for example, if we use 'https://<lightning.domain.com>/001/e', the new account popup will open. But I am unable to return to the original vf page from this popup page.
    – Ajinkyasd
    Dec 27, 2018 at 11:29
0

Created lightning component and added custom modal to edit records.

Used lightning:recordEditForm in custom modal : enter link description here

You must log in to answer this question.

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