Class: Connection

Connection

new Connection(options)

Connection class to keep the API session information and manage requests
Parameters:
Name Type Argument Description
options Object <optional>
Connection options
Properties
Name Type Argument Description
oauth2 OAuth2 | Object <optional>
OAuth2 instance or options to be passed to OAuth2 constructor
logLevel String <optional>
Output logging level (DEBUG|INFO|WARN|ERROR|FATAL)
version String <optional>
Salesforce API Version (without "v" prefix)
maxRequest Number <optional>
Max number of requests allowed in parallel call
loginUrl String <optional>
Salesforce Login Server URL (e.g. https://login.salesforce.com/)
instanceUrl String <optional>
Salesforce Instance URL (e.g. https://na1.salesforce.com/)
serverUrl String <optional>
Salesforce SOAP service endpoint URL (e.g. https://na1.salesforce.com/services/Soap/u/28.0)
accessToken String <optional>
Salesforce OAuth2 access token
sessionId String <optional>
Salesforce session ID
refreshToken String <optional>
Salesforce OAuth2 refresh token
Source:

Extends

  • events.EventEmitter

Members

analytics :Analytics

Analytics API object
Type:
Source:

apex :Apex

Apex REST API object
Type:
Source:

bulk :Bulk

Bulk API object
Type:
Source:

cache :Cache

Cache object for result
Type:
Source:

chatter :Chatter

Chatter API object
Type:
Source:

metadata :Metadata

Metadata API object
Type:
Source:

oauth2 :OAuth2

OAuth2 object
Type:
Source:

streaming :Streaming

Streaming API object
Type:
Source:

tooling :Tooling

Tooling API object
Type:
Source:

Methods

authorize(code, callback) → {Promise.<UserInfo>}

Authorize (using oauth2 web server flow)
Parameters:
Name Type Argument Description
code String Authorization code
callback Callback.<UserInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<UserInfo>

create(type, records, callback) → {Promise.<(RecordResult|Array.<RecordResult>)>}

Create records
Parameters:
Name Type Argument Description
type String SObject Type
records Record | Array.<Record> A record or array of records to create
callback Callback.<(RecordResult|Array.<RecordResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(RecordResult|Array.<RecordResult>)>

del(type, ids, callback) → {Promise.<(RecordResult|Array.<RecordResult>)>}

Synonym of Connection#destroy()
Parameters:
Name Type Argument Description
type String SObject Type
ids String | Array.<String> A ID or array of IDs to delete
callback Callback.<(RecordResult|Array.<RecordResult>)> <optional>
Callback
Source:
Returns:
Type
Promise.<(RecordResult|Array.<RecordResult>)>

delete(type, ids, callback) → {Promise.<(RecordResult|Array.<RecordResult>)>}

Synonym of Connection#destroy()
Parameters:
Name Type Argument Description
type String SObject Type
ids String | Array.<String> A ID or array of IDs to delete
callback Callback.<(RecordResult|Array.<RecordResult>)> <optional>
Callback
Source:
Returns:
Type
Promise.<(RecordResult|Array.<RecordResult>)>

deleted(type, start, end, callback) → {Promise.<DeletedRecordsInfo>}

Retrieve deleted records
Parameters:
Name Type Argument Description
type String SObject Type
start String | Date start date or string representing the start of the interval
end String | Date start date or string representing the end of the interval
callback Callback.<DeletedRecordsInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<DeletedRecordsInfo>

describe(type, callback) → {Promise.<DescribeSObjectResult>}

Describe SObject metadata
Parameters:
Name Type Argument Description
type String SObject Type
callback Callback.<DescribeSObjectResult> <optional>
Callback function
Source:
Returns:
Type
Promise.<DescribeSObjectResult>

describeGlobal(callback) → {Promise.<DescribeGlobalResult>}

Describe global SObjects
Parameters:
Name Type Argument Description
callback Callback.<DescribeGlobalResult> <optional>
Callback function
Source:
Returns:
Type
Promise.<DescribeGlobalResult>

describeSObject(type, callback) → {Promise.<DescribeSObjectResult>}

Synonym of Connection#describe()
Parameters:
Name Type Argument Description
type String SObject Type
callback Callback.<DescribeSObjectResult> <optional>
Callback function
Source:
Returns:
Type
Promise.<DescribeSObjectResult>

destroy(type, ids, callback) → {Promise.<(RecordResult|Array.<RecordResult>)>}

Delete records
Parameters:
Name Type Argument Description
type String SObject Type
ids String | Array.<String> A ID or array of IDs to delete
callback Callback.<(RecordResult|Array.<RecordResult>)> <optional>
Callback
Source:
Returns:
Type
Promise.<(RecordResult|Array.<RecordResult>)>

<protected> initialize(options)

Initialize connection.
Parameters:
Name Type Description
options Object Initialization options
Properties
Name Type Argument Description
instanceUrl String <optional>
Salesforce Instance URL (e.g. https://na1.salesforce.com/)
serverUrl String <optional>
Salesforce SOAP service endpoint URL (e.g. https://na1.salesforce.com/services/Soap/u/28.0)
accessToken String <optional>
Salesforce OAuth2 access token
sessionId String <optional>
Salesforce session ID
refreshToken String <optional>
Salesforce OAuth2 refresh token
userInfo UserInfo <optional>
Logged in user information
Source:

insert(type, records, callback) → {Promise.<(RecordResult|Array.<RecordResult>)>}

Synonym of Connection#create()
Parameters:
Name Type Argument Description
type String SObject Type
records Object | Array.<Object> A record or array of records to create
callback Callback.<(RecordResult|Array.<RecordResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(RecordResult|Array.<RecordResult>)>

login(username, password, callback) → {Promise.<UserInfo>}

Login to Salesforce
Parameters:
Name Type Argument Description
username String Salesforce username
password String Salesforce password (and security token, if required)
callback Callback.<UserInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<UserInfo>

loginByOAuth2(username, password, callback) → {Promise.<UserInfo>}

Login by OAuth2 username & password flow
Parameters:
Name Type Argument Description
username String Salesforce username
password String Salesforce password (and security token, if required)
callback Callback.<UserInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<UserInfo>

loginBySoap(username, password, callback) → {Promise.<UserInfo>}

Login by SOAP web service API
Parameters:
Name Type Argument Description
username String Salesforce username
password String Salesforce password (and security token, if required)
callback Callback.<UserInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<UserInfo>

logout(callback) → {Promise.<undefined>}

Logout the session by using SOAP web service API
Parameters:
Name Type Argument Description
callback Callback.<undefined> <optional>
Callback function
Source:
Returns:
Type
Promise.<undefined>

query(soql, callback) → {Query.<QueryResult>}

Execute query by using SOQL
Parameters:
Name Type Argument Description
soql String SOQL string
callback Callback.<QueryResult> <optional>
Callback function
Source:
Returns:
Type
Query.<QueryResult>

queryAll(soql, callback) → {Query.<QueryResult>}

Execute query by using SOQL, including deleted records
Parameters:
Name Type Argument Description
soql String SOQL string
callback Callback.<QueryResult> <optional>
Callback function
Source:
Returns:
Type
Query.<QueryResult>

queryMore(locator, callback) → {Query.<QueryResult>}

Query next record set by using query locator
Parameters:
Name Type Argument Description
locator String Next record set locator
callback Callback.<QueryResult> <optional>
Callback function
Source:
Returns:
Type
Query.<QueryResult>

recent(limit, callback) → {Promise.<Array.<RecordResult>>}

List recently viewed records
Parameters:
Name Type Argument Description
limit Number <optional>
Callback function
callback Callback.<Array.<RecordResult>> <optional>
Callback function
Source:
Returns:
Type
Promise.<Array.<RecordResult>>

retrieve(type, ids, callback) → {Promise.<(Record|Array.<Record>)>}

Retrieve specified records
Parameters:
Name Type Argument Description
type String SObject Type
ids String | Array.<String> A record ID or array of record IDs
callback Callback.<(Record|Array.<Record>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Record|Array.<Record>)>
Execute search by SOSL
Parameters:
Name Type Argument Description
sosl String SOSL string
callback Callback.<Array.<RecordResult>> <optional>
Callback function
Source:
Returns:
Type
Promise.<Array.<RecordResult>>

sobject(type) → {SObject}

Get SObject instance
Parameters:
Name Type Description
type String SObject Type
Source:
Returns:
Type
SObject

update(type, records, callback) → {Promise.<(RecordResult|Array.<RecordResult>)>}

Update records
Parameters:
Name Type Argument Description
type String SObject Type
records Record | Array.<Record> A record or array of records to update
callback Callback.<(RecordResult|Array.<RecordResult>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(RecordResult|Array.<RecordResult>)>

updated(type, start, end, callback) → {Promise.<UpdatedRecordsInfo>}

Retrieve updated records
Parameters:
Name Type Argument Description
type String SObject Type
start String | Date start date or string representing the start of the interval
end String | Date start date or string representing the end of the interval must be > start
callback Callback.<UpdatedRecordsInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<UpdatedRecordsInfo>

upsert(type, records, extIdField, callback) → {Promise.<(RecordResult|Array.<RecordResult>)>}

Upsert records
Parameters:
Name Type Argument Description
type String SObject Type
records Record | Array.<Record> Record or array of records to upsert
extIdField String External ID field name
callback Callback.<(RecordResult|Array.<RecordResult>)> <optional>
Callback
Source:
Returns:
Type
Promise.<(RecordResult|Array.<RecordResult>)>