Python In Salesforce Functions.
Finally, Python is Here in #Salesforce
With Spring 23 Python is now supported as a language for writing Salesforce Functions. Official Announcement here
Official Announcement
1. Salesforce Functions Let You Extend your Salesforce Business Logic to Any Demand
2. Functions are Written in Industry Standard Languages and they Run within the Salesforce trust Boundaries
3. The Code Written in Salesforce Functions Has a runtime of 2 minutes(Synchronous) and 15 minutes(Asynchronous) which is way more than What Normal Apex Offers i:e 10 Seconds (Synchronous) and 60 Seconds(Asynchronous ex. Batch)
Get Salesforce Developer’s stories in your inbox
Join Medium for free to get updates from this writer.
As of Today Salesforce Functions can be Written in Java, JavaScript, and TypeScript language, and from Spring 23 Python language is also supported. One of the great advantages is that we can leverage the Power of These language ecosystems and their wealthy Libraries and Frameworks. For ex. Java has tons Of Jar libraries, Similarly, NodeJS has NPM Packages and Python has its most popular package repository PyPI, which has libraries for almost any task. So Now with Salesforce functions, we can Utilize Higher Processing Power and The Entire Ecosystem of these industry Standard languages to Solve a complicated Task.
In This Example, We are Exploring the Python function although this Task Could be solved with Java Function using any Java library but, I wanted to Explore the Python language. Here The Task of The Python Function is to receive an Input PDF file, a Signature of a User, and a Signature Date from Salesforce and then Add the Signature and Date on the PDF and return it back to Salesforce. so if we had to do this Normally we would Create a VF page with merge fields and Render it as a PDF, the Problem is that if the Formatting or static content of the PDF is updated by Business then we might have to change the VF page accordingly. Python or Java Language has the capability to Directly Edit the PDF Documents using Its Rich libraries so any time Content changes we can pass the Updated PDF and the Function can edit the PDF itself instead of Creating a VF page.
The Steps to configure Python for Salesforce Functions are here
The Code Used for this example is available on this Github Repo Please watch the Demo of this Implementation.
Disclaimer:- Since Python is recently Announced I would advise you to Go through the official Documentation before implementing Real Business Solution. The Sole Purpose of this Example is to Just to show how powerful solutions we can Build with the combination of Low-Level Code(Flows) + Apex Code + Salesforce Function.








