Blog Projects
Escape Keys
A ColdFusion and Web Development Blog by Tom de Manincor
 

SalesForceCFC has been stable, but there is always room for improvement. This version includes a few tweaks and clean up.

Download the code @ RIAForge

I would also like to put out a 'Call for Features' to put on the roadmap for 1.0

Some already suggested:
-support for SOQL sub/nested queries
-asynchronous HTTP calls

Please post your suggestions on the Forums @ RIAForge or just leave a comment here.

In addition, I will be including a base unit test collection to provide stability for future releases and customization. Along with improved documentation and code samples.

I'd like to thank Daniel Llewellyn and Pete Freitag for their contributions, as well.

0.7 -CHANGE LOG- 1/24/2009
- enhancement - added support for batch save
- enhancement - added support for AssignmentHeader
- enhancement - added support for EmailHeader
- enhancement - added result size to query return data
- enhancement - updated typing and case of component
- enhancement - increased default SOAP timeout
- deprecated - unnecessary setters (setServerURL,setSessionId,setLastLogin)

SalesForceCFC Example Code

I apologize. I left out the test page and sample code from the latest release.

I've updated the project to include the Application.cfc, which is required for testing the security token persistence using the session scope. Along with the testForm.cfm, which has all the example code, and demo.

SalesForceCFC @ RIAforge

SalesForceCFC gets a BIG update!

This is a much improved release. It brings the object's architecture up to date, improves performance, and offers a few new features.

0.6 -CHANGE LOG- 2/22/2009 - enhancement - auto login
- enhancement - upgraded constructor
- enhancement - more getters and setters
- enhancement - last login added to instance
- enhancement - added utility calls getUserInfo and getServerTimeStamp
- enhancement - upgraded soap handling to minimize code
- enhancement - session handling added to test form to demo persistance
- deprecated - username and password parameters have been removed from login
- deprecated - objDataStruct on return from describeObject()
- fix - validate method getServerURL missing parenthesis
- fix - test form updated to avoid crossover and better cleanup

Download a copy at SalesForceCFC on RIAForge

It was brought to my attention, that you can not return more then 2000 records at a time using the query() method in the SalesForce API.

This is done to throttle performance and overhead when using the API. SF does make the data available, but it requires a few more steps.

I've integrated these steps and added the queryMore() method to salesForceCFC.

Along the way, queryObject() was updated to now accept a 'batchSize' argument. You can now specify the maximum number of records to return when doing a query. Similar to doing a SELECT TOP in MS SQL, or a LIMIT in regular SQL.

<cfset qAccount = oSF.queryObject(queryString = "SELECT Id, Name, createdDate FROM Account ORDER BY NAME", batchsize = '300') />

If there are more records then the batchSize you send in, then you will see a QUERYLOCATOR key in the return struct. It's a reference to your query on the SF server. It will remain available until there is 15 minutes of inactivity on it.

<cfset qAccountMore = oSF.queryMore(queryLocator = qAccount.queryLocator, startRow = qAccount.batchSize + 1, batchsize = 300) />

The 'queryLocator' gets passed in to the queryMore() method instead of passing in the queryString like you do in queryObject(). The option to 'includeRelatedObject' is still available with queryMore(), as is 'batchSize', and 'startRow'. One thing to note, is that SF will always return at least 200 records. So your batchSize should never be less then that.

With the new updates to this release, you now have the power to paginate any size query using the SalesForce API.

Download a copy at SalesForceCFC on RIAForge

A few updates were made in the 0.4 release available at:

salesForceCFC @ riaForge

A major and a minor fix have been implemented. The major being the lack of xmlFormat() in earlier releases. This would prevent characters like '<' to be passed as part of a queryString when using the queryObject() method.

There is now methods to manipulate the timeout value for SOAP requests and a getMemento() method that will return all values stored with the instance.

0.4 -CHANGE LOG- 4/5/2008
- enhancement - added timeout handling for cfhttp
- enhancement - added getMemento()
- fix - added xmlFormat() to query and save methods
- fix - disabled throwonerror for cfhttp to return accurate success

I am on the fence over the throwonerror setting, and looking for some feedback.

Version 0.3 now supports SalesForce's query language, SOQL's, relational queries. Which is their syntax for SQL JOINs. salesForceCFC now has the fields prefixed and built in to the resultset. With an option to include a struct of the entire object with each row.

For more on that, with this release comes the launch of the salesForceCFC demo site.

You'll need a SF account if you don't already have one. Developer account's are free and available at developer.salesforce.com.

v0.3 Change Log & Notes

Download Latest Release of salesForce CFC @ RIAforge.org

I appreciate the positive feedback and suggestions I have received on the initial release of salesForceCFC. So I took the time to put together some stuff that will help implement it.

The latest package includes a landing page, for testing and a link to the cfcdocs.

The test form, will run thru the basic creation of the object, login, and test each method. It is intended to be used as a diagnostic. I added a validate() method, as well. It checks the objects state and looks for an active secure session before trying to send any SOAP requests. The return structs will provide full error information and help you track down the cause quickly.

To download check out the project salesForceCFC at RIAForge

For the latest changes, instructions, and usage notes check out the readme.txt, now included with the package.

salesForceCFC
version: 0.2
date: 3/1/2008

-Overview-
This CFC allows you to connect and work with SalesForce.com,
one of the largest CRMs out there. It does so by generating SOAP requests,
and manipulating their responses.
This will make it easy to work with their SObjects,
and allow you to do more then just query.

-requirements-
ColdFusion 7 or Higher
Salesforce.com Account (Developer Accounts are freely available)

-installation-
1. place salesForceCFC folder inside root
2. browse to folder to run test form or view documentation

-usage-
you can copy the salesForce.cfc into any app and create objects
or map to it and use it from anywhere or in an object factory
remember to init() first, and then login() to activate a session

-note-
becareful with concurrency issues if using mutliple accounts.
it is not meant to be persistent if using more then 1 account.

0.2 -CHANGE LOG-
- feature - added landing page
- feature - added test form
- feature - added cfcDoc
- enhancement - created sendSoapRequest method and updated code
- enhancement - added validate method
- fix - retrieve now returns array of struct for results
- fix - added caching control for cfhttp and soap requests
- deprecated - hasActiveSession()

salesForceCFC

I was given the task to integrate with SalesForce.com, one of the largest CRM companies out there. At first glance, the API documentation on their site, which was at version 11.1 at the time, seemed like it was going to be a simple Webservice integration. Great, that should be fairly easy with CF.

Unfortunately, not. Some work forming the proper headers was going to be an issue. A little bit of google-ing, and I stumbled on a great thread hosted by Adobe. Some familiar names, such as Sean Corfield, were generous enough to post some working sample code. It used the webservice method and was able to query.

However, my goal was to modify data, as well as query. I continued to read on, and found some sample SOAP request code. Which I copied and tried with barely any modification, and was unsuccessful. I have to admit, I did not apply much effort to figuring out why it wasn't working. I had seen the option for a Java integration in the API documentation, and figured I'd be able to pull that off with some CF.

Wrong again. After days of monkeying around with sub-par results, I took it upon myself to find the 'best' solution. By best, I mean simplest, and quickest way to get this project out the door. So I decided to go back and look at the manual SOAP request sample code. It made sense, now its just a matter of getting it to work. I found some sample SOAP requests on the SF site, and went to town.

Finally, I was on a roll. All my requests were working, and responses were as expected. Couldn't stop there. I figured I owed it to the CF Community to take it to the next step. I wanted to make this CF friendly and return data types that would be easy to work with, rather then just SOAP responses. So I took the time to convert the responses over. Returning queries and structs to make things easier.

I hope it helps, and saves some time.

This is the initial release and has a caveat or two: - It is built around an ENTERPRISE account with SF. - It was tested against version 11.1 of the their API.

I will also be adding some documentation soon.

To download check out the project salesForceCFC at RIAForge

Feel free to contact me about any issues, suggestions, or general questions.