DeloitteEngineering Blog | Netherlands
14 October 2021

My experience with Salesforce Functions

Salesforce Apex can be leveraged for its strengths and now we can offload complex or resource intensive operations to a serverless Function!

What is it exactly?!

If you’re familiar with Amazon Lambda’s then you’ll recognize the similarity quite quickly. If you’re not familiar read on and I’ll try to walk you through what they are.

A Function is a piece of code which is deployed to the Salesforce Platform that can be ran on demand. Ok, we can do this on Salesforce already via a multitude of different approaches, what’s the significance here? Well a Function can be written in JavaScript (and now even Java)! This is significant as we finally begin to start writing code which can rely on existing open source dependencies! There are literally millions of dependencies which we can take advantage of.

Salesforce Apex can be leveraged for its strengths and now we can offload complex or resource intensive operations to a serverless Function without users even being aware!

Potential use cases

There are so many potential use cases for Salesforce Function’s, but I’ll try and point out which illustrates how to position them the best.

A few years ago I had the requirement to parse a Microsoft Excel spreadsheet in Salesforce. In Apex we cannot process these types of files very easily and definitely cannot if the file sizes can too large for us to handle. This particular spreadsheet was also extremely complex and particularly difficult to parse. Heroku came to the rescue in this case. Function’s really could have helped with parsing these types of files without having to manage a dedicated Heroku app which is always running.

Development experience

Creating a new Function from scratch is relatively simple. What stands out when beginning to work with Salesforce Function’s is that you’re initially building them locally on your own machine, whilst still having Salesforce connectively! Deploying the Function to the Salesforce Platform is a simple process of entering a couple of commands.

It’s extremely rare to write code which does not contain any issues the first time around. My experience with Salesforce Function’s development lifecycle was great as I was able to debug my quite simple Function locally on my machine. This is such a better development experience as it reduces the feedback cycle between writing, saving, executing, and seeing if it works.

What I really liked is that the code for your Function’s resides alongside your Salesforce code in the same repository! This is great for exposing these functions to other team members within the same project as well.

The future!

Previously, when faced with troublesome requirements which didn’t fit quite well within the strengths of Salesforce I’d offload the work to Heroku. This works great and utilizes both Salesforce and Heroku for its strengths. But… it’s not perfect. Sometimes I just need one piece of code to be executed. I don’t want to set up an entire app, and I certainly don’t want to worry about setting up and maintaining integrations!

My experience during the pilot was really positive and I’m now happy to see that they are now finally generally available!

Discover more about Salesforce Function’s on their documentation website.