-
Bug: Redirect on to custom VisualForce page on click of record (Condition Based). How to fix this?
Recently come up with a situation that on clicking a record it redirects me to an custom vf page on certain condition rather than on the detail page of Salesforce record.
I have changed the view button to override on to my vf page, but the error that I'm facing is
"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!
Error ID: 178978640-125263 (-1373969722)".
Below is my code:-
public with sharing class DetailPageOnClickingRecordCls {
public id accId{get;set;}
public Account accountDetail{get;set;}
public string accName{get;set;}public DetailPageOnClickingRecordCls(ApexPages.StandardController controller) {
}public PageReference doTest(){
accId = ApexPages.currentPage().getParameters().get('id');
accountDetail = new Account();
accountDetail = [select id,name from Account where id =: accId];
accName=accountDetail.name;
system.debug('accName::'+accName);
system.debug('accountDetail::'+accountDetail.id);
PageReference pageRef;
if(accName.substring(0,1)=='A'){
pageRef = new PageReference('/apex/DetailPageOnClickingRecord');
pageRef.setRedirect(false);
system.debug('hello in if');
//return pageRef;
}
else{
pageRef = Page.SelectableAccountPaginationDemo ;
pageRef.setRedirect(false);
system.debug('hello in else');
}
return pageRef;
}
}
Log In to reply.
Popular Salesforce Blogs

How Does a Post Install Script Work? - Salesforce Developer Guide
Post-Install Script is the same as other apex classes. And the apex class which is executed when a managed package is installed or upgraded. This…

All You Need to Know About Apex Testing in Salesforce | The Developer Guide
Apex Testing in Salesforce The Apex Testing enables us to write and execute tests for the Apex Code. An important phase of the Salesforce development…

How Salesforce Automation can Transform Your Business in 2024?
Salesforce Automation is a process to integrate a set of tools and techniques designed to streamline and automate various aspects of the sales process. It is…
Popular Salesforce Videos
How to Learn Salesforce Development | Salesforce learning steps for beginners | Trailhead demo
In this video, we shared the steps to learn salesforce lightning basics, salesforce apex development, CRM in online for free from scratch very quickly. Learn salesforce…
How the Salesforce Ecosystem Helped My Career
Welcome back to 100DaysofTrailhead.com! Your involvement in the Salesforce Ecosystem can be a great boost to your career. In this video, Eric talks about the…
How to write your first Apex program? | Salesforce Apex basics
In this video, we have explained that how you can write your first apex program in Salesforce. We used developer console to write the code.…