Apex Unit Testing: test data and Test.setMock

Posted by in apex, salesforce

Recently, I was QAing some Apex unit tests and I kept encountering the notorious Apex System.CalloutException: “You have uncommitted work pending. Please commit or rollback before calling out” while running a unit test that created some test data before performing a callout (that was properly mocked via Test.setMock). After some debugging, I realized the test only failed when I inserted the test data via my TestFactory class; when I created the test data directly inside the test method, the test passed. I think this must be an issue with the…read more

lookup –> picklist

Posted by in apex, salesforce, visualforce

I’ve had several clients “voice concerns” about’s lookup functionality relative to user acceptance. Well, if you’re dealing with a relatively simple lookup table, you can override an object’s new/edit page with a Visualforce page and display the lookup field to the user as a picklist.


extjs & visualforce (part 2), JSON this time

Posted by in apex, salesforce, visualforce

Let me preface this post by stating that the following is merely a proof of concept and should not necessarily be implemented into a production org. The pagination demonstrated below is not fit for large datasets and may result in unexpected behavior! Rich Waters’ comment on my first post re: Ext JS & visualforce got me thinking about the possibilities of leveraging JSON in Ext JS components within Visualforce, so I implemented a paging grid, similar to this example provided by Ext JS. OK, enough of the formalities, I suppose…read more


system log trick

Posted by in apex, salesforce

If you’ve ever used the system log in Salesforce, surely you’ve run into some code formatting issues. Fortunately, there’s a Firefox extension out there that will allow you to insert tabs in text areas. Now, I can actually tell what I’m doing in the system log. hth


wrapper class and sites

Posted by in apex, salesforce, visualforce Sites was announced last week at Dreamforce ‘08 and what a game changing announcement it was. Here’s my foray into Sites development, with nifty sample code…