Class: Connection

Connection

new Connection(optionsopt)

Connection class to keep the API session information and manage requests
Parameters:
Name Type Attributes Description
options Object <optional>
Connection options
Properties
Name Type Attributes 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
signedRequest String | Object <optional>
Salesforce Canvas signed request (Raw Base64 string, JSON string, or deserialized JSON)
proxyUrl String <optional>
Cross-domain proxy server URL, used in browser client, non Visualforce app.
callOptions Object <optional>
Call options used in each SOAP/REST API request. See manual.
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:

process :Process

Type:
Source:

soap :SoapApi

SOAP API object
Type:
Source:

streaming :Streaming

Streaming API object
Type:
Source:

tooling :Tooling

Tooling API object
Type:
Source:

Methods

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

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

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

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

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

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

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

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

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

Retrieve deleted records
Parameters:
Name Type Attributes 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, callbackopt) → {Promise.<DescribeSObjectResult>}

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

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

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

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

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

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

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

identity(callbackopt) → {Promise.<IdentityInfo>}

Get identity information of current user
Parameters:
Name Type Attributes Description
callback Callback.<IdentityInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<IdentityInfo>

(protected) initialize(options)

Initialize connection.
Parameters:
Name Type Description
options Object Initialization options
Properties
Name Type Attributes 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
signedRequest String | Object <optional>
Salesforce Canvas signed request (Raw Base64 string, JSON string, or deserialized JSON)
userInfo UserInfo <optional>
Logged in user information
Source:

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

Synonym of Connection#create()
Parameters:
Name Type Attributes 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>)>

limits(callbackopt) → {Promise.<LimitsInfo>}

Returns curren system limit in the organization
Parameters:
Name Type Attributes Description
callback Callback.<LimitsInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<LimitsInfo>

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

Login to Salesforce
Parameters:
Name Type Attributes 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, callbackopt) → {Promise.<UserInfo>}

Login by OAuth2 username & password flow
Parameters:
Name Type Attributes 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, callbackopt) → {Promise.<UserInfo>}

Login by SOAP web service API
Parameters:
Name Type Attributes 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(callbackopt) → {Promise.<undefined>}

Logout the current session
Parameters:
Name Type Attributes Description
callback Callback.<undefined> <optional>
Callback function
Source:
Returns:
Type
Promise.<undefined>

logoutByOAuth2(callbackopt) → {Promise.<undefined>}

Logout the current session by revoking access token via OAuth2 session revoke
Parameters:
Name Type Attributes Description
callback Callback.<undefined> <optional>
Callback function
Source:
Returns:
Type
Promise.<undefined>

logoutBySoap(callbackopt) → {Promise.<undefined>}

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

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

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

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

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

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

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

quickAction(actionName) → {QuickAction}

Get reference for specified global quick aciton
Parameters:
Name Type Description
actionName String Name of the global quick action
Source:
Returns:
Type
QuickAction

quickActions(callbackopt) → {Promise.<Array.<QuickAction~QuickActionInfo>>}

Returns all registered global quick actions
Parameters:
Name Type Attributes Description
callback Callback.<Array.<QuickAction~QuickActionInfo>> <optional>
Callback function
Source:
Returns:
Type
Promise.<Array.<QuickAction~QuickActionInfo>>

recent(typeopt, limitopt, callbackopt) → {Promise.<Array.<RecordResult>>}

List recently viewed records
Parameters:
Name Type Attributes Description
type String <optional>
SObject type
limit Number <optional>
Limit num to fetch
callback Callback.<Array.<RecordResult>> <optional>
Callback function
Source:
Returns:
Type
Promise.<Array.<RecordResult>>

request(request, optionsopt, callbackopt) → {Promise.<Object>}

Send REST API request with given HTTP request info, with connected session information. Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') , relative path from root ('/services/data/v32.0/sobjects/Account/describe') , or relative path from version root ('/sobjects/Account/describe').
Parameters:
Name Type Attributes Description
request String | Object HTTP request object or URL to GET request
Properties
Name Type Attributes Description
method String HTTP method URL to send HTTP request
url String URL to send HTTP request
headers Object <optional>
HTTP request headers in hash object (key-value)
options Object <optional>
HTTP API request options
callback Callback.<Object> <optional>
Callback function
Source:
Returns:
Type
Promise.<Object>

requestDelete(url, optionsopt, callbackopt) → {Promise.<Object>}

Send HTTP DELETE request Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') , relative path from root ('/services/data/v32.0/sobjects/Account/describe') , or relative path from version root ('/sobjects/Account/describe').
Parameters:
Name Type Attributes Description
url String Endpoint URL to request HTTP DELETE
options Object <optional>
HTTP API request options
callback Callback.<Object> <optional>
Callback function
Source:
Returns:
Type
Promise.<Object>

requestGet(url, optionsopt, callbackopt) → {Promise.<Object>}

Send HTTP GET request Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') , relative path from root ('/services/data/v32.0/sobjects/Account/describe') , or relative path from version root ('/sobjects/Account/describe').
Parameters:
Name Type Attributes Description
url String Endpoint URL to request HTTP GET
options Object <optional>
HTTP API request options
callback Callback.<Object> <optional>
Callback function
Source:
Returns:
Type
Promise.<Object>

requestPatch(url, body, optionsopt, callbackopt) → {Promise.<Object>}

Send HTTP PATCH request with JSON body Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') , relative path from root ('/services/data/v32.0/sobjects/Account/describe') , or relative path from version root ('/sobjects/Account/describe').
Parameters:
Name Type Attributes Description
url String Endpoint URL to request HTTP PATCH
body Object Any JS object which can be serialized to JSON
options Object <optional>
HTTP API request options
callback Callback.<Object> <optional>
Callback function
Source:
Returns:
Type
Promise.<Object>

requestPost(url, body, optionsopt, callbackopt) → {Promise.<Object>}

Send HTTP POST request with JSON body, with connected session information Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') , relative path from root ('/services/data/v32.0/sobjects/Account/describe') , or relative path from version root ('/sobjects/Account/describe').
Parameters:
Name Type Attributes Description
url String Endpoint URL to request HTTP POST
body Object Any JS object which can be serialized to JSON
options Object <optional>
HTTP API request options
callback Callback.<Object> <optional>
Callback function
Source:
Returns:
Type
Promise.<Object>

requestPut(url, body, optionsopt, callbackopt) → {Promise.<Object>}

Send HTTP PUT request with JSON body, with connected session information Endpoint URL can be absolute URL ('https://na1.salesforce.com/services/data/v32.0/sobjects/Account/describe') , relative path from root ('/services/data/v32.0/sobjects/Account/describe') , or relative path from version root ('/sobjects/Account/describe').
Parameters:
Name Type Attributes Description
url String Endpoint URL to request HTTP PUT
body Object Any JS object which can be serialized to JSON
options Object <optional>
HTTP API request options
callback Callback.<Object> <optional>
Callback function
Source:
Returns:
Type
Promise.<Object>

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

Retrieve specified records
Parameters:
Name Type Attributes Description
type String SObject Type
ids String | Array.<String> A record ID or array of record IDs
options Object <optional>
Options for rest api.
callback Callback.<(Record|Array.<Record>)> <optional>
Callback function
Source:
Returns:
Type
Promise.<(Record|Array.<Record>)>
Execute search by SOSL
Parameters:
Name Type Attributes 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

tabs(callbackopt) → {Promise.<TabsInfo>}

Returns a list of all tabs
Parameters:
Name Type Attributes Description
callback Callback.<TabsInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<TabsInfo>

theme(callbackopt) → {Promise.<ThemeInfo>}

Returns a theme info
Parameters:
Name Type Attributes Description
callback Callback.<ThemeInfo> <optional>
Callback function
Source:
Returns:
Type
Promise.<ThemeInfo>

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

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

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

Retrieve updated records
Parameters:
Name Type Attributes 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, optionsopt, callbackopt) → {Promise.<(RecordResult|Array.<RecordResult>)>}

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