Writing Unit Tests for v24 Apex REST Services

With the Spring '12 release, salesforce.com made some great enhancements to Apex REST services (v24): Apex REST automatically provides the REST request and response in your Apex REST methods via a static RestContext object. You no longer need to declare a RestRequest or RestResponse parameter in your method. User-defined…

Read more

Video - Debugging Apex Tools and Techniques (DF11)

The new System Log (aka Apex CSI) is a cool new part of Winter 12 that significantly reduces the pain of debugging Force.com applications. This is a great video from Dreamforce 11 showing you how to use the new console to debug code, set "breakpoints" and examine heap variables…

Read more

Salesforce Trigger when Rollups Summaries Not Possible

Master-Details relationships in Force.com ¬†are very handy but don't fit every scenario. For instance, it's not possible to implement a rollup summary on formula field or text fields. Here's a small trigger that you can use for a starter for these types of situations. The code for each class…

Read more

Roll Your Own Salesforce "Lookup" Popup Window

Let's talk about the standard salesforce.com "lookup" popup window for a few minutes. You know what I'm talking about.. this button right here It's a handy little button that pops up whenever you need to search for related records. It does a pretty good job but it has some…

Read more

OpportunityAccessLevel Not Writable

I was working on a project the other day where I needed to dynamically add users to an opportunity's Sales Team (OpportunityTeamMember object) so that users who do not normally have access to an opportunity based upon Org-wide security settings can work on the opportunity with other team members. One…

Read more

Dynamically Group & Display Query Results

I was working on a Visualforce page that displays the results of a query in separate PageBlock sections based upon a value in the query results. I ran into a small issue which took about an hour or so to solve, so I thought it might make descent blog fodder.…

Read more

Fun with Salesforce Collections

The Apex language provides developers with three classes (Set, List and Map) that make it easier to handle collections of objects. In a sense these collections work somewhat like arrays, except their size can change dynamically, and they have more advanced behaviors and easier access methods than arrays. If you…

Read more

Force.com Programming Best Practices

Wes and I are adding a few more topics to our Salesforce Handbook before we put it to bed and I thought a great topic would be programming best practices. I've never seen a "complete" list of best practices so I thought I would put something together based upon my…

Read more

Error - Portal account owner must have a role??

I wrote the following test class for a PRM deployment and received this crazy error when running the test: System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, portal account owner must have a role: [] I searched the message boards but couldn't find any reference to…

Read more

Managing the Heap in Salesforce.com

With the Spring '10 release, Salesforce.com removed the limit on the number of items a collection can hold. So now, instead of ensuring that your collections contain no more than 1000 items, you have to monitor your heap size. Here are some strategies on how to write Apex scripts…

Read more