Salesforce Functions are code you can run on demand which can be useful for resource intensive processing and automation tasks which you can hand over to functions which can offer an alternative to using Heroku or additional middleware.
The point of them is to reduce infrastructure overhead and reduce development time by integrating more natively to Salesforce. Some possible features are buildpacks, private and public spaces. I think with the introduction of Lightning Web Components and Salesforce Functions, the ecosystem will grow faster with developers coming in from outside the Salesforce Ecosystem.
Now let’s dive deeper to what’s coming and use cases for Salesforce functions. Similar to AWS Lambda functions, they will enable us to scale elastically and run on the demand. Amazon and Salesforce announced their partnership some time ago, and we already see its fruits with Service Cloud voice.
For example, there are contact flows you can use and invoke AWS Lambda functions on demand. An example use case is a callback request that can be asked to the caller if they wait longer than expected in a queue.
In Salesforce Functions, there’s more functionality where we will have native access to Salesforce data and can use languages such as Node.js, Java and Apex. The intended use cases support both declarative, low code and code-based solutions.
As the name suggests, you can do heavy processing for financial calculations or work order generation and leverage event-driven approach for file processing to data validation and cleaning jobs (from my experience this used to require custom integrations, AppExchange solutions or to defer this task to middleware).
These will enable us to get around platform limits like CPU and SOQL limits. There’s also security considerations for 3rd party apps that allow these solutions in the first place, luckily functions will also solve this by providing native access to your Salesforce org.
According to the demos and documentation, there are many ways you can invoke functions. Apex first comes to mind, but you can also call them from Flows, Lightning Web Components, Platform Events. Because the functions themselves can be published with platform-agnostic code (Node.js, Java) we will also have access to many libraries for different use cases that otherwise would be difficult to implement in Salesforce. Functions do not count against your Salesforce request limits and automatically scales will load as well.
I’m personally excited the amount of overhead functions can reduce by providing all security and compliance, without limits and without security tokens, identity management and so on.
They will also be supported for easier deployments through Salesforce CLI. Here’s a small sample of commands you can run on the CLI. Functions can be created from CLI and are located under the functions' directory of your project folder.
One tip from documentation stands out where for larger transactions, you can use an SDK that provides a UnitOfWork class to handle them. A UnitOfWork represents a set of one or more Salesforce operations that need to be done as a single atomic operation. This reduces the number of requests back to the org, and is more efficient when working with larger data volumes.
Transactions are helpful in making sure all related data changes are made at the same time, and in a way that can be undone if necessary. UnitOfWork also lets you manage data operations in your transactions. However, currently when using Node.js SDK, you should always have a new instance of UoW after each transaction.
Another thing to consider from the Apex side and Salesforce strongly recommends invoking functions async to get around generous timeout limits. Whether you’re invoking a function async or not, you must commit any DML in Apex so that you do not get a Callout Exception error. Functions run in a different context than Apex so their DML operations are not considered part of the Apex transaction.
Here’s the list of cases where you would get a Callout Exception:
There are also a few limits to consider: there’s a 2-minute timeout for response from a non async invoked function, but this limit is increased to 15 minutes for an async invocation and there’s no limit on the total number of them.
As we are learning more about functions, I suggest teams to try out Functions to give feedback and upskill in technologies like Node.js which can solve many problems we used to find ways to get around while developing in Salesforce. Thanks for reading, and I’ll see you in the next post!
Discover how Empaua's partnership with The Delta ecosystem empowers your business with exclusive benefits, discounts, and a collaborative hub for innovation and growth. Learn about the unique advantages of joining The Delta, including the upcoming Delta Campus in Berlin and Cape Town.
This brand refresh marks a significant chapter for Empaua, a step further towards becoming the leading Salesforce consultancy in Europe, as well as a step closer towards our group company, The Delta.
On this International Day of Charity, we share some touching stories from Lynette, Desmond and Carolina behind their favourite organisations and the profound motivations that drive their commitment to give back.
Unleashing Revenue Operations Excellence with Salesforce: A Perspective from our CEO, Steffi Kromer. Read more about this here.
Holding a substantial 19.8% share of the CRM vendor market, Salesforce is a pioneer in adopting AI capabilities and technologies. A tool that helps companies and small businesses track their customer relationships is Salesforce CRM. AI, on the other hand, uses data to make smart predictions and automate tasks.
Ally is a term that gets used a lot in the LGBTQ+ community. However, being an ally is not just a buzzword, it is a commitment that goes beyond a single month of celebration. As we mark PRIDE Month, let's dive deeper into what it means to be an ally and how to show meaningful support for the LGBTQ+ community.