Common APEX And Visualforce Errors And Solutions

June 28, 2013

Problem:  no viable alternative at character 

Solution: Make sure you don't mention enclose Strings with double quotes. quotes should be enclosed in single quotes.

Opportunity.Description__c='ABCD' NOT Opportunity.Description__c="ABCD"

Problem: Returning PageReference doesn't redirect to detail page

Solution (Possible):

Make sure DML statement insert or update is done before preparing and returning page reference. 

insert request;
PageReference pPage=new ApexPages.StandardController(request).view();
insert request;
return pPage;

Problem:  Incorrect code coverage OR Comments are considered for code coverage. OR Strange issues with code coverage. 


The solution to this problem is clearing the test Results log at the path where xyz is salesforce instance (ex: cs1,ap1 etc) or Go to Setup>Develop>Apex Test Execution>View Test History> Clear Test Results.

You Might Also Like


Popular Posts