Packagecom.salesforce
Classpublic class Connection
InheritanceConnection Inheritance flash.events.EventDispatcher
SubclassesAIRConnection

Main Salesforce ActionScript Connection object: query, create, update and delete Salesforce Database objects from ActionScript Flex2 applications. Create one connection object for each salesforce.com orginization that your Flex application will communicate with, normally just one connection object is needed. The connection object can be easily created in your appilcation using MXML markup as shown below. A Connection object can also be created using new Connection(), inside an action script source file. In the example below, sendRequest is just for debugging the soap messages, it is not required.


Example
<salesforce:Connection debugEvent="echoToDebugLog(event)" id="apexConn" sendRequest="sendRequestListener(event)"/>

See also

Apex Developer Doc


Public Properties
 PropertyDefined by
  applicationDomain : String
[read-only] Host and Domain name parsed from the server url, or localhost
Connection
  applicationServerName : String
[read-only] Server name parsed from the web services endpoint
Connection
  applicationUrl : String
URL web services endpoint, set in the login process
Connection
  batchSize : Number
[write-only] Change the default size of the batches returned from Query() and QueryMore(), the minimum size is 200, the maximum size is 2000 the system will also reserve the right to return other sizes, this is a suggestion.
Connection
  loginResult : LoginResult
[read-only]
Connection
  protocol : String
protocol to use, can be set to http, defaults to https
Connection
  serverUrl : String
Set in the login process by connection.loginWithCredentials() or loginWithSessionId(()
Connection
Public Methods
 MethodDefined by
  
Constructor for Connection class, no arguments
Connection
  
checkStatus(requestIds:Array, callback:IResponder):void
Connection
  
convertLead(leadConverts:Array, callback:IResponder):void
to be tested
Connection
  
create(sobjects:Array, callback:IResponder):void
Create new records in the salesforce database, pass in an array of SObjects, and a responder callback pair of functions
Connection
  
createObject(customObjects:Array, callback:IResponder):void
Connection
  
deleteIds(ids:Array, callback:IResponder):void
Delete a list of objects from salesforce.com database, the array contains just the id strings
Connection
  
deleteObject(customObjects:Array, callback:IResponder):void
Connection
  
describeGlobal(callback:IResponder):void
returns a list of all valid objects (table names) in the salesforce database, used to check that a desired table exists in a given database
Connection
  
describeLayout(type:String, recordTypes:Array, callback:IResponder):void
callback receives a complex data class desribing the meta-data used to layout a page for view or edit, you may specify an array of record type IDs to limit the amount of data returned if your object has many fields or record types.
Connection
  
describeSObject(type:String, callback:IResponder):void
use describeSObjects instead
Connection
  
describeSObjects(types:Array, callback:IResponder):void
return the object description in detail for one or more salesforce custom or standard objects
Connection
  
describeTabs(callback:IResponder):void
callback receives a structure describing all installed AppExchange applications for the current connection, including a list of object tabs for each application.
Connection
  
execute(packageName:String, method:String, args:Array, callback:IResponder, isArray:Boolean = false):void
Used to execute Apex Code packages (Apex Code is currently in developer preview)
Connection
  
Use this method to determine if a connection has or has not been initialized by loginWithCredentials() or loginWithSessionId() via an scontrol
Connection
  
getDeleted(sObjectType:String, startDate:Date, endDate:Date, callback:IResponder):void
given a time range, returns a list of records ( of any type) that were deleted in that time window, resulting IDs can be passed into undelete, or used to purge remote systems of records that are deleted in the salesforce system
Connection
  
getServerTimestamp(callback:IResponder):void
Retrieves the current system timestamp (Greenwich Mean Time (GMT) or Coordinated Universal Time (UTC) time zone) from the API.
Connection
  
getUpdated(sObjectType:String, startDate:Date, endDate:Date, callback:IResponder):void
list the objects that have been updated by the system in the time windows passed in
Connection
  
getUserInfo(callback:IResponder):void
Retrieves personal information for the user associated with the current session.
Connection
  
isSControl():Boolean
used to detect if we are running from inside a SControl on the hosted Apex platform
Connection
  
login(loginRequest:LoginRequest):void
unified login request, will perform one of loginWithSessionId, or loginWithCredentials depending on the information provided in the request structure
Connection
  
merge(mergeRequest:MergeRequest, callback:IResponder):void
to be tested
Connection
  
process(actions:Array, callback:IResponder):void
to be tested
Connection
  
query(queryString:String, callback:IResponder):void
Query table or table and related tables using Salesforce SOQL language strings, the responder will return the results asynchronously to the callback functions (response,fault)
Connection
  
queryAll(queryString:String, callback:IResponder):void
this version of query will include in it's scope the recycle bin as well as the live data
Connection
  
queryMore(queryLocator:Object, callback:IResponder):void
looping portion of the query() queryMore() method for accessing large data sets
Connection
  
resetPassword(userId:String, callback:IResponder):void
Changes a user’s password to a temporary, system-generated value.
Connection
  
retrieve(fieldList:String, sObjectType:String, ids:Array, callback:IResponder):void
Retrieve a list of sobjects given an array of object ids
Connection
  
search(searchString:String, callback:IResponder):void
search for objects in one or more tables within the salesforce database
Connection
  
sendEmail(messgeList:Array, callback:IResponder):void
send an email or mass email from the system
Connection
  
setPassword(userId:String, password:String, callback:IResponder):void
Sets the specified user’s password to the specified value.
Connection
  
undelete(ids:Array, callback:IResponder):void
to be tested
Connection
  
update(sobjects:Array, callback:IResponder):void
Update existing records in the salesforce database, the array of sobjects must have a valid ID filled in for each record to be updated
Connection
  
updateObject(customObjects:Array, callback:IResponder):void
Connection
  
upsert(externalIDFieldName:String, sobjects:Array, callback:IResponder):void
utility function that will perform a create or update depending on the presence of an existing record that matches the provided external key field
Connection
Events
 EventSummaryDefined by
   Event used to print out the SOAP messages used in the API transport methods Connection
   Event used internaly to collect responses and pass them back to the responder callbacks Connection
Property detail
applicationDomainproperty
applicationDomain:String  [read-only]

Host and Domain name parsed from the server url, or localhost

Implementation
    public function get applicationDomain():String
applicationServerNameproperty 
applicationServerName:String  [read-only]

Server name parsed from the web services endpoint

Implementation
    public function get applicationServerName():String
applicationUrlproperty 
applicationUrl:String  [read-write]

URL web services endpoint, set in the login process

Implementation
    public function get applicationUrl():String
    public function set applicationUrl(value:String):void
batchSizeproperty 
batchSize:Number  [write-only]

Change the default size of the batches returned from Query() and QueryMore(), the minimum size is 200, the maximum size is 2000 the system will also reserve the right to return other sizes, this is a suggestion.

Implementation
    public function set batchSize(value:Number):void
_loginCallbackproperty 
salesforce_internal var _loginCallback:IResponder = null
loginResultproperty 
loginResult:LoginResult  [read-only]Implementation
    public function get loginResult():LoginResult
protocolproperty 
protocol:String  [read-write]

protocol to use, can be set to http, defaults to https

Implementation
    public function get protocol():String
    public function set protocol(value:String):void
serverUrlproperty 
serverUrl:String  [read-write]

Set in the login process by connection.loginWithCredentials() or loginWithSessionId(()

Implementation
    public function get serverUrl():String
    public function set serverUrl(value:String):void

See also

Constructor detail
Connection()constructor
public function Connection()

Constructor for Connection class, no arguments

Method detail
checkStatus()method
public function checkStatus(requestIds:Array, callback:IResponder):voidParameters
requestIds:Array
 
callback:IResponder
convertLead()method 
public function convertLead(leadConverts:Array, callback:IResponder):void

to be tested

Parameters
leadConverts:Array
 
callback:IResponder
create()method 
public function create(sobjects:Array, callback:IResponder):void

Create new records in the salesforce database, pass in an array of SObjects, and a responder callback pair of functions

Parameters
sobjects:Array — array of SObjects
 
callback:IResponder

See also

createObject()method 
public function createObject(customObjects:Array, callback:IResponder):voidParameters
customObjects:Array
 
callback:IResponder
deleteIds()method 
public function deleteIds(ids:Array, callback:IResponder):void

Delete a list of objects from salesforce.com database, the array contains just the id strings

Parameters
ids:Array — list of id strings for objects to be delted
 
callback:IResponder
deleteObject()method 
public function deleteObject(customObjects:Array, callback:IResponder):voidParameters
customObjects:Array
 
callback:IResponder
describeGlobal()method 
public function describeGlobal(callback:IResponder):void

returns a list of all valid objects (table names) in the salesforce database, used to check that a desired table exists in a given database

Parameters
callback:IResponder
describeLayout()method 
public function describeLayout(type:String, recordTypes:Array, callback:IResponder):void

callback receives a complex data class desribing the meta-data used to layout a page for view or edit, you may specify an array of record type IDs to limit the amount of data returned if your object has many fields or record types.

Parameters
type:String
 
recordTypes:Array
 
callback:IResponder
describeSObject()method 
public function describeSObject(type:String, callback:IResponder):void

use describeSObjects instead

Parameters
type:String
 
callback:IResponder
describeSObjects()method 
public function describeSObjects(types:Array, callback:IResponder):void

return the object description in detail for one or more salesforce custom or standard objects

Parameters
types:Array — array of strings listing the types, ex: ["Account","Task"]
 
callback:IResponder
describeTabs()method 
public function describeTabs(callback:IResponder):void

callback receives a structure describing all installed AppExchange applications for the current connection, including a list of object tabs for each application.

Parameters
callback:IResponder
execute()method 
public function execute(packageName:String, method:String, args:Array, callback:IResponder, isArray:Boolean = false):void

Used to execute Apex Code packages (Apex Code is currently in developer preview)

Parameters
packageName:String
 
method:String
 
args:Array
 
callback:IResponder
 
isArray:Boolean (default = false)
getCurrentSessionid()method 
public function getCurrentSessionid():String

Use this method to determine if a connection has or has not been initialized by loginWithCredentials() or loginWithSessionId() via an scontrol

Returns
String — the session that was set upon login or load, or null if no session has been created, note this sessionid will expire
getDeleted()method 
public function getDeleted(sObjectType:String, startDate:Date, endDate:Date, callback:IResponder):void

given a time range, returns a list of records ( of any type) that were deleted in that time window, resulting IDs can be passed into undelete, or used to purge remote systems of records that are deleted in the salesforce system

Parameters
sObjectType:String
 
startDate:Date
 
endDate:Date
 
callback:IResponder
getServerTimestamp()method 
public function getServerTimestamp(callback:IResponder):void

Retrieves the current system timestamp (Greenwich Mean Time (GMT) or Coordinated Universal Time (UTC) time zone) from the API. responder will be called with a timestamp from the server, used to record when an getUpdated or getDeleted call was last made, or to syncronize unrelated systems.

Parameters
callback:IResponder
getUpdated()method 
public function getUpdated(sObjectType:String, startDate:Date, endDate:Date, callback:IResponder):void

list the objects that have been updated by the system in the time windows passed in

Parameters
sObjectType:String
 
startDate:Date
 
endDate:Date
 
callback:IResponder

See also

getUserInfo()method 
public function getUserInfo(callback:IResponder):void

Retrieves personal information for the user associated with the current session.

Parameters
callback:IResponder
isSControl()method 
public function isSControl():Boolean

used to detect if we are running from inside a SControl on the hosted Apex platform

Returns
Boolean — True if we are running from a SWF loaded onto Salesforce.com SControl , False if running from a localhost or local filesystem
login()method 
public function login(loginRequest:LoginRequest):void

unified login request, will perform one of loginWithSessionId, or loginWithCredentials depending on the information provided in the request structure

Parameters
loginRequest:LoginRequest
merge()method 
public function merge(mergeRequest:MergeRequest, callback:IResponder):void

to be tested

Parameters
mergeRequest:MergeRequest
 
callback:IResponder
process()method 
public function process(actions:Array, callback:IResponder):void

to be tested

Parameters
actions:Array
 
callback:IResponder
query()method 
public function query(queryString:String, callback:IResponder):void

Query table or table and related tables using Salesforce SOQL language strings, the responder will return the results asynchronously to the callback functions (response,fault)

Parameters
queryString:String
 
callback:IResponder

See also

queryAll()method 
public function queryAll(queryString:String, callback:IResponder):void

this version of query will include in it's scope the recycle bin as well as the live data

Parameters
queryString:String
 
callback:IResponder
queryMore()method 
public function queryMore(queryLocator:Object, callback:IResponder):void

looping portion of the query() queryMore() method for accessing large data sets

Parameters
queryLocator:Object
 
callback:IResponder

See also

resetPassword()method 
public function resetPassword(userId:String, callback:IResponder):void

Changes a user’s password to a temporary, system-generated value.

Parameters
userId:String
 
callback:IResponder
retrieve()method 
public function retrieve(fieldList:String, sObjectType:String, ids:Array, callback:IResponder):void

Retrieve a list of sobjects given an array of object ids

Parameters
fieldList:String — string which lists the api names for fields to return to the responder
 
sObjectType:String — name of the object in the database
 
ids:Array — list of object ids (strings)
 
callback:IResponder

See also

search()method 
public function search(searchString:String, callback:IResponder):void

search for objects in one or more tables within the salesforce database

Parameters
searchString:String
 
callback:IResponder

See also

sendEmail()method 
public function sendEmail(messgeList:Array, callback:IResponder):void

send an email or mass email from the system

Parameters
messgeList:Array
 
callback:IResponder

See also

com.objects.SingleEmailMessage
setPassword()method 
public function setPassword(userId:String, password:String, callback:IResponder):void

Sets the specified user’s password to the specified value.

Parameters
userId:String
 
password:String
 
callback:IResponder
undelete()method 
public function undelete(ids:Array, callback:IResponder):void

to be tested

Parameters
ids:Array
 
callback:IResponder
update()method 
public function update(sobjects:Array, callback:IResponder):void

Update existing records in the salesforce database, the array of sobjects must have a valid ID filled in for each record to be updated

Parameters
sobjects:Array — array of SObjects
 
callback:IResponder

See also

updateObject()method 
public function updateObject(customObjects:Array, callback:IResponder):voidParameters
customObjects:Array
 
callback:IResponder
upsert()method 
public function upsert(externalIDFieldName:String, sobjects:Array, callback:IResponder):void

utility function that will perform a create or update depending on the presence of an existing record that matches the provided external key field

Parameters
externalIDFieldName:String — external field, if no matching record found, new record is created otherwise performs an update
 
sobjects:Array — list of objects to update or create
 
callback:IResponder
Event detail
debugEventevent 
Event object type: com.salesforce.events.DebugEvent

Event used to print out the SOAP messages used in the API transport methods

sendRequestevent  
Event object type: com.salesforce.events.SendEvent

Event used internaly to collect responses and pass them back to the responder callbacks