You need to sign in to do that
Don't have an account?
kishna 15
How to redirect record detail page in lightning using apex
How to redirect account record detail page using below code
public PageReference save(string id) {
System.debug('Entered');
PageReference nextPage = new PageReference('/'+id+'/view');
nextPage.setRedirect(true);
return nextPage;
}
Thanks.........
public PageReference save(string id) {
System.debug('Entered');
PageReference nextPage = new PageReference('/'+id+'/view');
nextPage.setRedirect(true);
return nextPage;
}
Thanks.........
Greetings to you!
I tried to research your problem and found some solution which might help you.
If you want to use your page in lightning only then you can use:
However, if you want to use your page in both classic and lightning then you can use getUiThemeDisplayed ()
These are the values:
Theme1—Obsolete Salesforce theme
Theme2—Salesforce Classic 2005 user interface theme
Theme3—Salesforce Classic 2010 user interface theme
Theme4d—Modern “Lightning Experience” Salesforce theme
Theme4t—Salesforce mobile app theme
Theme4u—Lightning Console theme
PortalDefault—Salesforce Customer Portal theme
Webstore—Salesforce AppExchange theme
So, you have to use if condition like this:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
You can try below url
Best Regards,
Sandhya
Thanks for quick response I am getting below error
An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.
Thank you again for your patience and assistance. And thanks for using salesforce.com!
Thanks for quick response
I have tried below condition it is not working for me
'lightning/r/My_Custom_SObject__c/' + customRecord.Id + '/view'
Actually, this is a known issue. Visualforce Page reference id not working on Lightning.
Please refer to the below link for more information.
https://success.salesforce.com/issues_view?id=a1p3A0000001BrUQAU&title=visualforce-page-reference-id-not-working-on-lightning
And there is no workaround available. But it is in a review and we may get a solution for this soon.
I hope it helps you.
Kindly mark this as solved if the information was helpful.
Thanks and Regards,
Khan Anas
I am able to collect current record id from URL but same URL id not able pass in lightning
public class contactQuery {
public list<Contact> contacts{get;set;}
public contactQuery(ApexPages.StandardController controller){
id accid=ApexPages.currentPage().getParameters().get('id');
contacts=[select id,firstname,lastname,phone from contact where accountid=:accid];
save(accid);
}
public PageReference save(string id) {
System.debug('Entered');
PageReference pg = new PageReference('/'+id+'/view');
pg.setRedirect(true);
return pg;
}
}