Wednesday, February 22, 2012

SFDC API 24.0 test failure issue

Yesterday I was experiencing a weird issue.

For a new requirement we did development in our DEV environment…We wrote new test methods and we thought the work is done :)... 
However, there were Null Pointer Exceptions when we ran the test methods.
And it was pointing to the custom settings….we doubled checked and confirmed that the custom setting had the default values. Also, it was accessible to anyone (public).

After some time I realized that the test method API version was 24.0.. I changed it to 23.0 and there were no errors :)

Edit - SFDC has introduced test classes not to access data directly with API 24. Even though it is a good move , I would like to access certain info by default like custom settings, and Pricebook. But there is always an option to use @istest(seealldata=true) to access live data.


http://boards.developerforce.com/t5/General-Development/Custom-setting-not-accessible-from-test-class/m-p/399669#M66636

Saturday, February 4, 2012

Account address to be displayed as single block

Small code snippet to display Account address as a single block just like in standard page

<apex:outputText label="Shipping Address"
                    escape="false"
                    value="{!IF(NOT(ISNULL(Account.ShippingStreet)),'{0}<br/>{1}, {2} {3}<br/>{4}', '&nbsp;')}">
                   
                    <apex:param value="{!Account.ShippingStreet}" />
                    <apex:param value="{!Account.ShippingCity}" />
                    <apex:param value="{!Account.ShippingState}" />
                    <apex:param value="{!Account.ShippingPostalCode}" />
                    <apex:param value="{!Account.ShippingCountry}" />
                </apex:outputText>