My desired end result for this project is when a lead record is converted to person account, an HTTP callout will be made to update and external MySQL database.

My initial approach was to utilize the PHP toolkit and have the MySQL database updated via PHP connection to salesforce, but with this approach I cannot have the update occur in real time and I would like the data send be triggered from salesforce, not from a time based inquiry by the SQL database.

Has anyone had success with using REST integrated with MySQL? It appears this approach would require a plugin to MySQL to support REST and all reviews I have found show this may be unstable?

My other thought was to develop a Heroku app to act as a connector between the two. What would the most effective approach be to update the MySQL database from a salesforce triggered event?

To summarize my desired flow:

1) Lead object is converted to person account

2) On lead conversion, basic client data is sent to update MySQL database on external server.

OR (alternate functionality considered)

1) Custom button to be added to lead object to send data to the MySQL database.

Any other ideas to make this connection from salesforce to MySQL are appreciated as long as they are not time based. I need this to function either via trigger or class code called from custom button (real time). Thanks everyone in advance for any ideas or suggestions!!!

1 Answer 1


I would create a trigger on creation of the person account. This trigger would make a webservice callout (using the @future notation on the method because triggers cannot directly make callouts).

You would receive this callout with a custom endpoint in PHP that receives the POST data from the Salesforce web callout and inserts it into the MySQL database.

Say you have an object named myObject that has attributes Name and Date. You can have a php file named (for example) endpoint.php on your server. In your php file you can have something similar to the following:

$myObjectJSON = $_POST['myObj'];
$myObject = json_decode($json);

//You can now access the data in the object like this:

//Then insert the data into MySQL

Then you would call http://www.yourserver.com/endpoint.php in the Apex callout, passing the appropriate data. In Apex:

HttpRequest req = new HttpRequest();


myObj x = new myObj();
myObj.Name = 'A Name'; 
myObj.Date = System.Today();  

String JSONString = JSON.serialize(myObj);                


Http http = new Http();
HTTPResponse res = http.send(req);
  • This pattern is very useful for realtime updates to MySQL. Can be used with URL-encoded data as well. Hosting the php script on my database server and have almost realtime updates.
    – JoshuaWS
    Jan 26, 2017 at 3:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .