-
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

Secure Coding Practices for Salesforce Developers
If you have worked on the Salesforce platform for over a few minutes, whether you're a developer or a Salesforce certified admin, you've likely heard…

Why Should You Use Historical Trend Reporting Salesforce
Historical Trend Reporting is a speciality detailing highlights accessible on Salesforce. It allows for daily and weekly analyses of changes in forecasts, cases, opportunities, or…

A Guide to Listing App or Product on Salesforce AppExchange
To create a Salesforce App, coding experience is not mandatory. Apex and JavaScript are the key languages used in Salesforce App development. However, one can…
Popular Salesforce Videos
How Do You Create Sandboxes in a Professional Edition in Salesforce?
Eric Stafford asks, “How do you create Sandboxes in a Professional Edition?” and gets an expert answer and demo from LeeAnne Rimel, Architect, Admin Evangelism…
Nonprofit Summit 2022 - Go Further with Salesforce Reports and Dashboards Hands-on Training
Salesforce reports and dashboards are the analytical sides of CRM. They are used to convert business requirements into Visual representations like Graphs, Pie Charts, Tables,…
Understanding Products & Pricebooks in Salesforce
In this video, Shrey gave detailed information about products and pricebooks You will also learn: 1. How to add and manage Products in Salesforce? 2.…