Tahoe Dreamin’ 18: Getting your project started with Salesforce DX

I presented about Getting your project started with Salesforce DX at Tahoe Dreamin’ 18:

I also brought beers from Alberta Brewing, hopefully you were able to try them!

Comments Off

Dreamforce 2017: Scripting DX: Using Build Tools to Automate your Development

Here’s the recording of my Dreamforce 2017 presentation Scripting DX: Using Build Tools to Automate your Development, in did in collaboration with Bryan Leboff.

Hope to see you there!

Comments Off

Whitelist All IPs for Salesforce Chrome Extension

So it’s been awhile since Enable All Trusted IP Ranges for a Salesforce Org actually worked, because Salesforce disabled the ability for homepage components to run javascript around Summer, 2015.

There was a workaround logged as a Github issue which simply ran the javascript from the homepage component in the developer console, and that seemed to work, I referred people there. It wasn’t really elegant, but it worked.

I’ve had it on my plate to create a browser extension to perform this capability ever since. A few days ago, I was going to manually add an IP to Setup => Security Controls => Network Access, and I saw a button called “Allow All Ranges (!)”. I clicked it, and sure enough, it actually added all IP ranges! I looked through all of my installed Chrome extensions, and didn’t see any of them that advertised this feature. I disabled them one-by-one until I found the culprit: Apex Debugger by motiko. Browsing the source, motiko attributed my original post for that piece. I asked motiko about it in email, asked for permission to publish this feature standalone, and he agreed.

So I spent a couple hours, stripped out everything but this feature, packaged it up, paid the $5 registration fee, and put it on the Chrome Web store: https://chrome.google.com/webstore/detail/whitelist-all-ips-for-sal/nnlnikmkkbpgioojghgojoejgcheilic.

Here’s a quick video on how it works:

Please let me know if you have any questions via twitter. Cheers!

Oh, and the source is on github.

Comments Off

Apex: Booleans can be null

Apex on Salesforce is a subset of Java. In general a Java developer should feel right at home when creating Apex.

One of the things I encountered recently where Java and Apex differ is the ability to access Primitives. For example, Java has a boolean type, which can be true or false. Additionally, there’s a Boolean type, which can be true, false, or null, and can be used in Collections because it inherits from Object. If using the latter, the consumer need always check for null before checking true or false.

Apex does not have access to Primitive Data Types, only those which inherit from Object. Therefore this issue can result:

Boolean isError;
if (isError) {

This will fail with:

System.NullPointerException: Attempt to de-reference a null object

Unless you instantiated the Boolean to a true/false, you must check for null before checking whether it’s true or false. Alternatively, you can explicitly check for true (which feels wrong, but would circumvent the issue):

Boolean isError;
if (isError == true) {

No issue results.

I saw this recently when I queried a Checkbox field on an object. I created the Checkbox field AFTER the record was created, so each of the existing records default the Checkbox (Boolean) field to null, instead of false as you might expect.

In summary:
The Best Practice for dealing with Booleans in Apex is to explicitly check for == true/false

if (Boolean == true)

rather than use the shorthand.

if (Boolean)

Hat tip to Jeegar Brahmakshatriya for the help.

Tagged | Comments Off