AppleScript connector for Salesforce.com
The AppleScript connector allows you to make calls to the Salesforce.com Web Services API from applescript, enabling you to highly customize and integrate your desktop OSX environment with Salesforce.com.
Getting goingDownload the application (Requires OSX 10.5 or later), and drop it in your applications folder. The name of the application is called SalesforceScripting, so every script would start with
tell application "SalesforceScripting"
Starting a new User Session.
Create a new Account in Salesforce (note that like the web api, create can take multiple objects, and returns a list of SaveResult objects)set mySession to login username "firstname.lastname@example.org" password "mypassword(and possibly security token)"
Check for errors when creating/updating recordsset acc to make SObject set type of acc to "Account" acc setField named "Name" to "My New Account" set res to mySession create sobjects acc Id of first item of res
Querying Salesforce.comset cont to make SObject set type of cont to "Contact" cont setField named "LastName" to "blowy" set resList to session create sobjects cont set res to first item of resList if success of res then display dialog "created contact, Id is " & Id of res else display dialog "couldn't create contact " & StatusCode of res & ":" & message of res end if
See the users properties from UserInfoset res to query mySession soql "select id, name, annualrevenue, createdDate, createdBy.Name from account order by createdDate desc" set L to (get every SObject of res) repeat with row in L Id of row -- the Salesforce.com record Id type of row -- the SObject type, e.g. Account row value of "Name" -- get the Name field row value of "CreatedBy.Name" -- shortcut to get the Name field of the CreatedBy related user object row dateValue of "CreatedDate" -- the date/time value of the CreatedDate field row numberValue of "AnnualRevenue" -- the number from the annual revenue field end repeat
Show the user an interactive login dialogtell application "SalesforceScripting" set session to login with saved credentials set u to users info of session serverUrl of session sessionId of session username of u userId of u profileId of u end tell
Examine the results of a describeGlobal calltell application "SalesforceScripting" set session to show login window -- do something with session end tell
Look at field Describestell application "SalesforceScripting" set session to login with saved credentials name of every SObjectDescribe in session whose custom is false end tell
API Call log windowtell application "SalesforceScripting" set session to login with saved credentials set d to first SObjectDescribe in session whose name is equal to "Account" set f to first FieldDescribe in d whose name is equal to "OwnerId" label of f end tell
Still things to do, including
- Diagnostics window
Release HistorySalesforceScripting is open source, see the Github project.
v0.6 July 16, 2010M
- Fixed issue related to the success flag on the Save Result object.
v0.5 June 4, 2010
- explicit describeGlobal command removed, always done automatically.
- fields collection added to SObjectDescribe, this automatically calls describeSObject as needed.
- a new fields property added to SObject that returns the names of the fields that have values.
- a new optional flag to setDateValue called dateOnly can be used to indicate that the field being set is a date only field.
- A new API Log diagnostic window has been added, see a summary of API calls made to Salesforce.com by the application.
v0.4 June 3, 2010
- Updated to a new version of zkSforce (soon to be published) that is both OSX & iPhone/iPad compatible.
- Added describeGlobal (either call describeGlobal directly, or example the DescribeSObjects collection of the session, and it'll get called automatically for you).
- Added queryMore, you can pass either a string queryLocator, or the previous QueryResult object as the locator parameter.
v0.3 June 2, 2010
- Fixed problems with auto-updater not working. (you'll need to manually update to this version)
v0.2 June 2, 2010
- Added deleteRecords call to session (make a delete api call)
- Added a usersInfo property to session that returns a UserInfo that contains the properties from the userInfo structure returned by login (username, name, email, currencyCode, userId etc).
- Added better error handling, SOAP faults are now passed through into AppleScript errors.
- Added new login commands, "show login window" to show a username/password/server dialog to the user, and "login with saved credentials" to login using the last successfully used credentials (assuming you opted to store the password in the keychain). Any authentication error will result in showing the regular login dialog to the user.
v0.1 June 1, 2010
- Initial release, has support for login, query, create & update.