function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sam AlterSam Alter 

Python backend for Salesforce

Is it possible to have a Python backend for Salesforce? I have a Python script that accesses fields from Salesforce (using simple_salesforce) and does some calculations. Now, I want to dump the output of these calculations back into Salesforce. Is there a way to accomplish this?

Thanks!
Varun PareekVarun Pareek
Sam - I belive your are fetching data from Salesforce using the query() method and once you have the data in the python "heap", you do some sort of calculations and then you want to update the same records or may be even insert new records? I am not very much familiar with how simple_salesforce works but I believe you still can insert/update into Salesforce using a few commands. This is what I found out from the documentation:
https://pypi.python.org/pypi/simple-salesforce
Sam AlterSam Alter
Thanks Varun, yes I am using the query() method indeed! I will look into the insert/update, hopefully either of those will allow me to accomplish what I'm trying. What I really want is to be able to trigger the Python script from Salesforce, say by clicking a "Compute" button, run the script, which queries the existing records, runs calculations, and updates some other fields within the record in question. So, I don't want to update all records, but only a specific record at hand.

The main question here is, how to trigger Python from within Salesforce, from the client side? Any ideas?

Thanks a ton!
Sam
Joe OndrejckaJoe Ondrejcka
Sam, 

I recommend
1) Creating an Button that calls an Apex Class that makes an API call to your python script, or 2) use a Workflow, triggered by a record update to send an Outbound Message to your API scipt. 

Cheers, 

Joe