Monday, May 9, 2016

Mix Groovy and Java in IntellJ IDEA

To mix Java and Groovy together in the same IntelliJ IDEA project, a simple change can be made to the project's .iml file. By default, when the project is created it only looks for source files and test files in the src/main/java directory.
By adding two sourceFolder elements IntellJ will automatically find and compile .groovy files in the Groovy directory.

Wednesday, May 4, 2016

Go to Assembla Ticket

Here's a simple JS code that can be converted into a bookmarklet to quickly open an Assembla ticket.

Saturday, April 30, 2016

HTTP/REST API Specifications

Now that I have the pleasure of designing new APIs to support both B2C and B2B use cases, my first thought is to standardize. In the case of APIs, I believe standards reduce the burden of maintenance and improve the ease of integration.

To that end, I sought to define guidelines for all operations. These are not new or novel, but I need these to set shared expectations with my team. And we start with a few core principles:

  1. Follow REST conventions for CRUD operations
  2. Use JSON in all request and response bodies (Content-Type: application/json)...
  3. Except where binary content is involved (Content-Type: multipart/form-data)

REST conventions


Striving to KISS:

Error response body


Success responses will contain appropriate data for the request, but all error response bodies look alike. At least structurally, having only one field.

  • Array<Error> errors - An array of any errors encountered while executing the operation. This field is always present for an error state (any non-200 HTTP status).


Each errors element has the following fields:

  • int code - "for programmatic consumption" (ref Braintree)
  • String message - "for human consumption" (ref Braintree)
  • String component - Whatever we're blaming for the error

Tuesday, February 2, 2016

Get Full DateTime Format (GMT) in Apex

To get the full DateTime format in GMT such that it's compatible with Apex methods like JSON.deserialize(),  the most accurate method is to call DateTime.formatGmt().


For comparison, below are some other alternatives for generating similar String values for a DateTime object.

Monday, January 11, 2016

6 Reasons You Got the Generic Error Page

Sometimes in Visualforce, you'll have debug logging enabled for a community or portal user, but loading a page fails with no trace of what went wrong. When you look in the debug log for an explanation, all you see is that Salesforce successfully loaded the Generic Error Page configured for the site.


Before logging a case or asking a fellow developer for help, check for the following 6 common culprits.

  • Are you missing any static resources, {!$Resource.__}?
  • Are you missing any custom labels, {!$Label.__}?
  • Are you missing any custom permissions, {!$Permission.__}?
  • Are you missing any page references, {!$Page.__}?
  • Are you missing any custom controller/extension properties bound on the page? This can be a problem when deploying packages among sandbox orgs.
  • Are you missing any custom controller/extension actions bound on the page?

What I've also discovered, interestingly enough, is that for some reason using MavensMate v6.0.0 with Sublime Text 3, saving a Visualforce page or component skips the validation for global variables used in Visualforce.

Wednesday, November 18, 2015

Why Consultants Should Learn to Type

$100,000,000,000.

How's that for an answer to the title question? If you're wondering where that came from, the answer's simple. Let's conservatively estimate the size of the consulting industry to be $200 billion[1][2]. Without adding more people, what would happen if the productivity of people already in the industry increases by 50%? That 50% would amount to $100 billion, and that's the reason I believe all consultants should learn how to type.

Okay, lest my alma mater revokes my MBA, I'll admit right now my posit is a gross exaggeration based on unrealistic assumptions. So I'm off... but by how much?

50% is bogus. Or is it?


"The average person types between 38 and 40 words per minute... However, professional typists type ... upwards of 65 to 75 WPM."[3] The difference between the professional typist and the average person is simply that the professional typist learned to type. And my adjusted typing speed is 87 WPM, even with a wrist injury.



#yawn So what? So if you're not typing at least at the pace of a professional typist, consider yourself handicapped. Not in a derogatory way, simply such that you have much untapped potential.

Try an analogy


Take human speech as an example. Here are two clips below from two consultants pitching their firms to win a project. Which one would you hire?

Consultant A


Consultant B


You've probably figured out that it's the same voice recording, with the modified clip slowed to 67% of the original. But isn't the difference obvious? If you wouldn't hire the second guy because he spoke so slowly, why should you settle for the guy who types that way?

Keep in mind that typing is not rocket science. All it takes is scheduled time and practice.

Imagine if


... John the business analyst suddenly produces 50% more:
  • Detailed notes from meetings
  • Thorough functional requirements
  • Accurate and comprehensive documentation

... Jane the app developer suddenly produces 50% more:
  • Code
  • Code comments
  • Regression test automation

... Jill the project manager suddenly produces 50% more:
  • Personalized stakeholder communications
  • Risk reports and mitigation strategies
  • Next phase project proposals

... everyone shared and collaborated 50% more on enterprise platforms! (Chatter, anyone?)

The value gained from a 50% increase in typing speed is not proportional. I believe it's exponential. People who have speech impediments tend to speak less. You can guess that people who have typing impediments will avoid mediums where typing is the means to communicate.

And if your consultants, your organization doesn't care to address people's typing skills, aren't you leaving money on the table from your investments in typing-based platforms like SharePoint? Salesforce? Confluence?

Closing thoughts


I believe we owe it to ourselves, to our companies, to our economies, to learn this simple skill that catalyzes collaboration and value creation in the digital age. And if you're a company, teaching your people to type is a one-time investment that will pay lifetime dividends.

Saturday, October 31, 2015

Field Update + Update Records + Apex Trigger = ?

While the "Triggers and Order of Execution" page in the Winter '16 Force.com Apex Code Developer's Guide gives good information about the high-level order of operations, developers reading it are still unclear about how complex interactions unfold across objects that use workflow rules, Apex triggers, and Process Builder ("PB") processes.

Let's take a relatively simple set of automation applied to a single object:

  • A workflow rule with a field update
  • A recursion-enabled process that updates the record which starts the process
  • An Apex trigger

When a transaction is processed, how many times do each of the above automation components execute in that single transaction? The answers below may surprise you/

Component TypeNum Executions
Workflow Rule1
Process6
Trigger8

The exact step order in which the components were executed is illustrated below.

Workflow RuleProcessTrigger
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

The takeaway should be that developers ought to be very careful when adding automation to an environment that uses "all of the above", meaning workflow rules, processes, and triggers.