Creating SalesForce Accounts and Contacts with ColdFusion
Just a quick example. I recently was tasked with adding contact form information directly into SalesForce. While the SalesForce API isn't that difficult, sometimes just getting the ins and outs of an API call can be time-consuming. Thankfully I was aware that Tom de Manincor had posted his SalesForceCFC on RIAForge. This component has thankfully already wrapped up the complexity of the API calls for you so all you need to do is a little bit of digging in the SalesForce API to understand what objects to create and methods to call.
Firstly, you should sign up for a developer account with SalesForce to test out working with their API. This allows you to add and delete items without worrying you are going against your real company account information. Once you have done this do not forget to get your security token otherwise the login will fail (you pass your password with the token appended). The following is just a basic example of how you would first log in to your developer account, create an Account object and then place a Contact object under that account using SalesForceCFC:
<cfset salesforce = createObject("component","salesforce").init("email","passwordWithSecurityToken") />
<cfset loginResult = salesforce.login() />
<cfdump var="#loginResult#" />
<cfset account = {
Name="Remote Synthesis",
Website="http://www.remotesynthesis.com"
} />
<cfset accountResult = salesforce.saveObject("Account",account,"create") />
<cfdump var="#accountResult#" />
<cfset contact = {
AccountId=accountResult.id,
Email="brian@email.com",
FirstName="Brian",
LastName="Rinaldi",
HomePhone="617-123-4567",
MailingCity="Brighton",
MailingPostalCode="12345",
MailingState="MA",
MailingStreet="9 Cold Fusion Rd."
} />
<cfset contactResult = salesforce.saveObject("Contact",contact,"create") />
<cfdump var="#contactResult#" />
There are currently no comments for this entry.
