You need to sign in to do that
Don't have an account?
Aakash Solanki 7
Overriding a standard edit button with vf page is not working properly in lightning
I have overridden the standard Edit button with visual force in salesforce, When tryin to edit a record in salesforce it perfectly redirects to the detail page but when I try to replicate the same thing in lightning sticking to the visual force page only, it doesn't redirect to the record detail page.
Here is my Apex Controller :-
public PageReference getEditRedir(){
system.debug('Entered into getEditRedir() of ' + DispatchRequestExtCnt.class);
string retURLId= ApexPages.currentPage().getParameters().get('retURL');
String recId = ApexPages.currentPage().getParameters().get('id');
Request__c req = [select Id,Name,RecordType.Name,RecordType.Id from Request__c where Id=: recId ];
String recName = req.RecordType.Name ;
if(recName.contains('Plan Economics Review Request'))
{
pageRef = new PageReference('/apex/PlanEconomicsReviewNew');
}else{
pageRef = new PageReference('/' + req.id + '/e');
}
inputRecType = req.RecordType.Id;
pageRef.getParameters().put('id', req.id);
pageRef.getParameters().put('mode', 'edit');
pageRef.getParameters().put('nooverride', '1');
pageRef.getParameters().put('retURL', req.id);
pageRef.getParameters().put('RecordType', inputRecType);
pageRef.getParameters().put('ent', 'Request__c');
pageRef.setRedirect(true);
system.debug('Leaving from getEditRedir() of ' + DispatchRequestExtCnt.class);
return pageRef;
}
Here is my VF Page code :-
<apex:page standardController="Request__c" extensions="DispatchRequestExtCnt"
action="{!nullValue(editRedir.url, urlFor($Action.Request__c.Edit, Request__c.id, null, true))}">
</apex:page>
Please suggest a solution.
Here is my Apex Controller :-
public PageReference getEditRedir(){
system.debug('Entered into getEditRedir() of ' + DispatchRequestExtCnt.class);
string retURLId= ApexPages.currentPage().getParameters().get('retURL');
String recId = ApexPages.currentPage().getParameters().get('id');
Request__c req = [select Id,Name,RecordType.Name,RecordType.Id from Request__c where Id=: recId ];
String recName = req.RecordType.Name ;
if(recName.contains('Plan Economics Review Request'))
{
pageRef = new PageReference('/apex/PlanEconomicsReviewNew');
}else{
pageRef = new PageReference('/' + req.id + '/e');
}
inputRecType = req.RecordType.Id;
pageRef.getParameters().put('id', req.id);
pageRef.getParameters().put('mode', 'edit');
pageRef.getParameters().put('nooverride', '1');
pageRef.getParameters().put('retURL', req.id);
pageRef.getParameters().put('RecordType', inputRecType);
pageRef.getParameters().put('ent', 'Request__c');
pageRef.setRedirect(true);
system.debug('Leaving from getEditRedir() of ' + DispatchRequestExtCnt.class);
return pageRef;
}
Here is my VF Page code :-
<apex:page standardController="Request__c" extensions="DispatchRequestExtCnt"
action="{!nullValue(editRedir.url, urlFor($Action.Request__c.Edit, Request__c.id, null, true))}">
</apex:page>
Please suggest a solution.
Make sure that you have checked this
Use the Salesforce Classic override—Inherits the behavior from the Salesforce Classic Override setting.
Refer below help article.
https://help.salesforce.com/articleView?id=links_customize_override.htm&type=5
Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.
Best Regards,
Sandhya
When overriding the standard edit button, In "Lightning Experience Override" I have checked Salesforce classic override. It works fine in classic but when it moves to lightning mode, it doesn't work properly.
Regards,
Aakash