Common APEX And Visualforce Errors And Solutions

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();
pPage.setRedirect(true);
insert request;
return pPage;

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

Workaround:

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

http://salesforcetipsntricks.blogspot.in/2012/03/strange-issue-with-code-coverage-in.html

Comments

Popular posts from this blog

How to prepare your LOB app for Intune?

Information Architecture - Setup your term store to scale

Generate token signing .CER from ADFS Federation Metadata XML