Salesforce functions are a new feature in salesforce development. They let you extend the Customer 360 Platform with custom elastically–scalable business logic. Salesforce Functions are designed to boost productivity by reducing your infrastructure responsibilities and enabling you to build and integrate Functions-as-a-Service (FaaS) using the languages and tools of your choice.
A cloud function is a single–purposed, on demand, short-lived micro service without complex infrastructure.
- Single purposed because it will solve a specific problem or operation.
- On demand because, depending on the traffic or the amount of users that need to consume the function, function resources will scale elastically. In other words, it’s going to automatically adapt to the amount of traffic that is coming to this specific service.
- Microservice because we are not going to be adding a lot of different logic into a function, we are going to try to create functions that are very specific to a problem.
- Without complex infrastructure as we don’t have to worry about how the function is deployed, where it is running, how to configure it. Everything is taken care for us, in this case by the salesforce team.
It’s going to adapt its resources depending on demand: if we are receiving a lot of traffic, the function is going to scale by adding more computational resources to be able to manage all this traffic. If instead, we are not receiving any traffic at all, the function is pretty much going to shut down until more traffic arrives.
On trusted infrastructure means that it is running within the salesforce trusted boundary, so we don’t need to set up any authentication or authorization resources to be able to access salesforce services from a function.
The best way to recognize if we need a function is to ask yourself:
Let’s say we have a certain organization activity, and we are doing some operation that may hit the governor limits. In that case, we need a function, because probably we need more precession power.
This is usually the case for querying quote lines and products, calculating price rules, updating quotes, accessing external databases, etcetera.
Generally speaking, if an operation doesn’t need to be within a transaction and is reaching closer to governor limits, it might be a good idea to use cloud functions.
If I’m within the governor and apex limits, I would continue using apex, as it’s still the core language for the salesforce platform.
The best way to start learning about salesforce functions is through the functions recipe sample application in Github. You can also read more about it from salesforce documentation, and finally on trailhead.
To recap, this is a new feature that is going to allow us to have cloud functions, such as AWS lambdas or Azure functions, but within the salesforce environment. This new feature salesforce is offering us is new, so we must wait to see how the pricing model will be, and the changes that this new feature will bring to the development of the salesforces organizations.