Strange APEX unit test behavior when splitting SOQL queries (or any line of code for that matter)

Today I ran into an odd situation. Writing some APEX test code, I noticed that coverage for an APEX SOQL query is calculated in an odd way. It seems that splitting SOQL queries across multiple lines might add up to less coverage than creating a long SOQL statement on 1 line. This is particularly strange, since one of the best-practises when writing code, is to create readable code, splitting long SOQL queries across multiple lines. It is actually an element that’s part of the scoring by judges, when taking the SFDC Advanced Developer practical assignment.

Ofcourse, splitting a SOQL query across … Continue Reading

Creating flexible APEX triggers

It has been way too long since my last post, that’s why I decided to take some time to explain a concept that will make specifically APEX triggers more flexible.

Normally, when modifying an APEX trigger, one would need to change the code in a sandbox, modify any existing test-code and then deploy these changes into production. This may not always be necessary, as you can move some of your trigger behavior to the setup menu, allowing an admin to change the trigger logic.

As an example, let’s take a trigger on Opportunity that needs to execute some kind of logic, … Continue Reading

My First Heroku

Salesforce.com recently acquired an on-demand platform for Ruby on Rails applications: Heroku. Before this event, I had never even heard of Heroku, nor did I ever do any Ruby on Rails. The mere fact that a visionary company like Salesforce.com obviously found the technology interesting enough to acquire it, I could not resist giving it a go. My primary focus was to get a better understanding of what Heroku is and where it fits in the application development spectrum. After making sure sufficient coffee was at … Continue Reading

Salesforce.com: Dynamic reporting on all Accounts within the same hierarchy

Today a colleague at Vivens CRM came with an interesting question. “How can I create a link on the Account page, that opens a report of ALL opportunities for this Account plus those of other Accounts within the same hierarchy?”. After some thinking, I came up with the following solution.

The trick here is to somehow group all Accounts in the same hierarchy in some way, so that the report can fetch all Opportunities, for all the Accounts inside this group. Grouping the Accounts can be done, using a formula field, which should hold the same value, … Continue Reading

The power of Force.com – Enforcing one ‘unique’ primary Contact per Account

Force.com is a powerfull platform, with loads of application development tools. You might be using workflow to automate a process, validation rules to validate (user) input, required/unique fields to keep the database uncorrupted…. I can go on and on about out-of-the-box features that you get with relatively no effort. The platform becomes even more powerfull when you combine the features to achieve something that might seem impossible at first glance. Let’s have a look at an example.

Enforcing one ‘unique’ primary Contact per Account

When you build Salesforce.com applications, often there is a need for one primary Contact per Account. You could … Continue Reading

Auto Chatter

This month the Chatter Developer Challenge was on. The goal was to develop an application that employs Chatter, Salesforce.com’s newest collaboration feature. As a devoted Force.com developer I could not resist to submit an entry.

The biggest challenge was to think of an actually usefull application. Obviously, Chatter allows to create 100′s of funny apps, but my goal was to actually give it some business value.

Here’s what I came up with: Chatter Escalation! The app allows an admin to set up objects to monitor, based on self-defined criteria. Now, whenever these criteria apply, the system will automatically add a … Continue Reading

Adding a picture to the Contact detail page

It has been a long time since my last post, so I decided it was time to add something to my little blog. During last week’s Dev401 class in Doorn, The Netherlands, I got a question how to easily add a picture to the page for a Contact. Here’s the solution we chose.

There’s a lot of ways to do this. For example, you could upload a picture of a Contact to the Documents and refering to this document by Id on the Contact page with a formula field. This is a bit tedious, so you might not want to repeat … Continue Reading

Salesforce.com Advanced Search

The Salesforce.com search feature (the one in the sidebar), searches some standard fields on the appropriate objects, along with external Id fields. Custom fields marked as external Id will be searched as well. But what if you want to search through a text-base custom field which is NOT an external Id?

To search other custom text fields in Salesforce.com, you should choose the Advanced Search option. Advanced search is located on screen of it’s own, allowing you to search more fields, also custom one’s. Some people find it annoying to first have to go to this Advanced search screen to be … Continue Reading

Salesforce Country fields as picklists

Thanks to entire the Doorn Dev501-class of Januari 2010, I switched to WordPress! Unanimously the class recommended it over Serendipity, which I had some trouble with, especially when posting code samples. So far WordPress looks very good!

To kick it off, let’s repost my initial post of the previous blog….

 It will transform all the country fields on Leads, Contacts and Accounts to picklists. Since Salesforce offers the address fields in a pretty strict format, changing the country-text-fields to anything else than text fields is not possible by using any of the -otherwise pretty powerfull- Salesforce setup tools.

Here’s what it will look like…. Continue Reading