Salesforce: Sending emails from communities doesn’t work

I’ve been doing a lot of work with Communities AKA Experience Sites recently and encountered an issue where emails sent using the Apex method Messaging.sendEmail() were not be received by the recipient. The strange thing was that the debug logs showed that the email had been successfully sent, and the associated Activity record had been created. And thus began many hours of debugging to understand the root cause and its fix. I tried the usual suspects: None of the above worked. When I checked the Email Logs there was still no entry for the email despite the Apex code saying it had successfully gone out. Then I came across an article in the Winter ’24 release notes saying the email addresses must be verified to send emails through Salesforce. Aha! Or so I thought. For standard Salesforce users, you’ll see “[Verified]” next to their email address. Or, if they’re not …

Read more

A Beginner’s Guide to Object-Oriented Programming with Apex: 3. Polymorphism

This is part 3 in the series “A Beginner’s Guide to Object-Oriented Programming with Apex” and will cover the aspect of Polymorphism. For other posts in this series see the links below. A Beginner’s Guide to Object-Oriented Programming with Apex What the hell is Polymorphism? Polymorphism has the funkiest name and is my favourite aspect of OOP. If done correctly you will feel like a proper genius. Originating from Greek words, polymorphism more or less means “many forms”. This gives away very little unless you know polymorphism quite well but essentially polymorphism describes the ability of a type e.g. a set of differing Apex classes, to be used in similar ways without knowing much about those classes. An immediate example on the platform is the Type.format() static method available on Integers, DateTime, etc**. Although each of the Types represents something different this method does a similar thing for each i.e. turns …

Read more

A Beginner’s Guide to Object-Oriented Programming with Apex: 2. Abstraction

This is part 3 in the series “A Beginner’s Guide to Object-Oriented Programming with Apex” and will cover the aspect of Abstraction. For other posts in this series see the links below. A Beginner’s Guide to Object-Oriented Programming with Apex What the hell is Abstraction? Abstraction is a very interesting and surprisingly simple concept. At its core it’s about context and if Abstraction were a company it’s motto would be “Provide the right tools and data at the right time.”. There are many analogies in the “real world” e.g. Where is this applicable to developers on the platform? Ever created a Visualforce component or Apex utility class? Well you my friend you are already using abstraction! This sounds a lot like Encapsulation! Abstraction and Encapsulation go hand in hand but they are different. Encapsulation is one of the ways you can achieve abstraction but does not encompass the entire concept. …

Read more

Unit Test Data Consistency

I’m sure every Apex developer has had their Developer Org data interfere with their unit testing. Or perhaps you have coded unit tests that function perfectly within your Developer Org but when deployed to another Org fail because of a different, partial or empty database.

Of course as a developer this type on inconsistency within your work environment is extremely counter-productive. Initially I developed a methodology that did the job but wasn’t nearly as concise as I would have liked. More recently however I’ve developed a technical solution that is universal as well as quick to implement.

Read more

VisualForce Component Ids & Javascript

I have retired this approach in favour of a much neater solution that can be found here.

Salesforce used in conjunction with JavaScript and Ajax can be pretty smashing. I’ve used a number of JavaScript libraries that make you want to high-five yourself when implemented. There can(and probably will) be some frustration while you bend a library and make it fit within the Salesforce framework, although Ron Hess has some pretty sweet examples for you to pore over.

One simple frustration I’ve come across is that of retrieving elements by Id. Salesforce has an intelligent scheme in place which ensures that HTML elements don’t have duplicate Ids and therefore conform to W3C standards.

Read more

Datatable VS Repeat

A long long time ago, in an office not far away I pondered the need for so much variety in the VisualForce ‘structural’ component library. I mean, dataTables, pageBlockTables, outputPanels, panelGrids, repeats, panelBars.. jeez Louise. And when would I use them all? How should I combine them? If I type google in google will I break the Internet? Okay, I didn’t really ponder the last one, everyone knows that’s true.

Nowadays I’d like to think I have a feel for what to use, and when. More specifically I’m going to dig into when to use dataTables over repeats, and vice versa(The only real difference I can find between pageBlockTable and dataTable is that dataTable has a cool onhover JS handler that highlights the currently onhovered row, so I’m totally going to ignore pageBlockTable. Speak to the hand pageBlockTable, because the face ain’t listening).

Read more

Salesforce, Bugs & You

Bugs. Bleh. As far as I know Salesforce doesn’t maintain a list of ‘Known Issues’ and sadly this can mean hours poring over code, trying to find where you went wrong, and eventually finding that it wasn’t your code at all. Of course it wasn’t, because you are perfect. Go on give yourself a hug.

To this end I’ll post bugs as I find them and if you feel like contributing, mail me a few of your own. Some buggy areas are quite obscure, so I’ll start with a common one, the infamous ‘Null Param passed by a CommandButton’. Dun dun duh.

Read more

Visualforce & Dynamic CSS

When I started working on the Force.com platform CSS was an area that made me sad a bit. Deep down. Overriding the Salesforce CSS is a nightmare and I would recommend you don’t begin the dark and daunting journey down that path. Rather start afresh, you’ll thank me later.

That said, dealing with CSS on the platform can still be a timeconsuming task. Especially if you are incorporting images into your pages using CSS. My initial process was something similar to this:

  1. Create a stylesheet and some styles. Hopefully you’ve done a good job because you have no way of quick-previewing the result.
  2. Include said stylesheet and all referenced images in a zip file. Take care to preserve the directory structure so that you can reference all stylesheet and image files correctly.
  3. Upload the zip file as a static resource.
  4. Create references to the stylesheet in appropriate pages.
  5. View page. Realise you need to move one of your outputPanels 3px right. Be sad. Deep down. Goto 1.

Read more

VisualForce Tag Cloud Component

Tag clouds are nothing new on the interwebs, but there is some debate as to which sort of implementation is best. In this debate I prefer the simplest solution [insert further debate as to the definition of ‘simplest’ here] which I propose to be a simple unordered HTML list with some CSS styling.

Furthermore, wouldn’t it be great if this solution were dynamic, thus enabling you to create tag clouds specific to a particular application context?. Rhetorical question, of course it would be. To this end I’ve created a component that utilises a controller, mostly dynamic in nature.

To start with, let’s have a look at the component code

Read more

Salesforce Managed Packages

This is one area of the Salesforce.com platform that I’m no fan of.

In short, you code a complex application and it’s beautiful. You marvel at the wonder of the sleek UI, the intelligent complexity of the code, and the comprehensive unit testing you’ve implemented. Now you wish to package your application up, advertise it briefly and have the customers pour in. Not so fast my friend.

Packaging can be a nightmare, and there are certain hurdles to this step that you won’t find officially documented.

Read more