salesforce@4.2.2
Functions
- bulk(sObject, operation, options, fun)
- bulkQuery(qs, options, callback)
- cleanupState(state)
- create(sObject, attrs)
- createConnection(state)
- createIf(logical, sObject, attrs)
- describe(sObject)
- describeAll()
- destroy(sObject, attrs, options)
- execute(operations)
- login(state)
- query(qs)
- reference(position)
- relationship(relationshipName, externalId, dataSource)
- retrieve(sObject, id, callback)
- steps()
- update(sObject, attrs)
- upsert(sObject, externalId, attrs)
- upsertIf(logical, sObject, externalId, attrs)
bulk
bulk(sObject, operation, options, fun) ⇒ Operation
Create and execute a bulk job.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
sObject | String | API name of the sObject. |
operation | String | The bulk operation to be performed |
options | Object | Options passed to the bulk api. |
fun | function | A function which takes state and returns an array. |
Example
bulk('Patient__c', 'insert', { failOnError: true, pollInterval: 3000, pollTimeout: 240000 }, state => {
return state.data.someArray.map(x => {
return { 'Age__c': x.age, 'Name': x.name }
})
});
bulkQuery
bulkQuery(qs, options, callback) ⇒ Operation
Execute an SOQL Bulk Query.
This function uses bulk query to efficiently query large data sets and reduce the number of API requests.
Note that in an event of a query error,
error logs will be printed but the operation will not throw the error.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
qs | String | A query string. |
options | Object | Options passed to the bulk api. |
[options.pollTimeout] | integer | Polling timeout in milliseconds. |
[options.pollInterval] | integer | Polling interval in milliseconds. |
callback | function | A callback to execute once the record is retrieved |
Example (The results will be available on `state.data`)
bulkQuery(state=> `SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.field1}'`);
Example
bulkQuery(
(state) =>
`SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.field1}'`,
{ pollTimeout: 10000, pollInterval: 6000 }
);
cleanupState
cleanupState(state) ⇒ State
Removes unserializable keys from the state.
Kind: global function
Param | Type |
---|---|
state | State |
Example
cleanupState(state)
create
create(sObject, attrs) ⇒ Operation
Create a new object.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
sObject | String | API name of the sObject. |
attrs | Object | Field attributes for the new object. |
Example
create('obj_name', {
attr1: "foo",
attr2: "bar"
})
createConnection
createConnection(state) ⇒ State
Creates a connection.
Kind: global function
Param | Type | Description |
---|---|---|
state | State | Runtime state. |
Example
createConnection(state)
createIf
createIf(logical, sObject, attrs) ⇒ Operation
Create a new object if conditions are met.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
logical | boolean | a logical statement that will be evaluated. |
sObject | String | API name of the sObject. |
attrs | Object | Field attributes for the new object. |
Example
createIf(true, 'obj_name', {
attr1: "foo",
attr2: "bar"
})
describe
describe(sObject) ⇒ Operation
Outputs basic information about an sObject to STDOUT
.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
sObject | String | API name of the sObject. |
Example
describe('obj_name')
describeAll
describeAll() ⇒ Operation
Outputs basic information about available sObjects.
Kind: global function
Access: public
Example
describeAll()
destroy
destroy(sObject, attrs, options) ⇒ Operation
Delete records of an object.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
sObject | String | API name of the sObject. |
attrs | Object | Array of IDs of records to delete. |
options | Object | Options for the destroy delete operation. |
Example
destroy('obj_name', [
'0060n00000JQWHYAA5',
'0090n00000JQEWHYAA5
], { failOnError: true })
execute
execute(operations) ⇒ State
Executes an operation.
Kind: global function
Param | Type | Description |
---|---|---|
operations | Operation | Operations |
login
login(state) ⇒ State
Performs a login.
Kind: global function
Param | Type | Description |
---|---|---|
state | State | Runtime state. |
Example
login(state)
query
query(qs) ⇒ Operation
Execute an SOQL query.
Note that in an event of a query error,
error logs will be printed but the operation will not throw the error.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
qs | String | A query string. |
Example
query(`SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.field1}'`);
reference
reference(position) ⇒ State
Get a reference ID by an index.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
position | number | Position for references array. |
Example
reference(0)
relationship
relationship(relationshipName, externalId, dataSource) ⇒ object
Adds a lookup relation or 'dome insert' to a record.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
relationshipName | string | __r relationship field on the record. |
externalId | string | Salesforce ExternalID field. |
dataSource | string | resolvable source. |
Example
Data Sourced Value:
relationship("relationship_name__r", "externalID on related object", dataSource("path"))
Fixed Value:
relationship("relationship_name__r", "externalID on related object", "hello world")
retrieve
retrieve(sObject, id, callback) ⇒ Operation
Retrieves a Salesforce sObject(s).
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
sObject | String | The sObject to retrieve |
id | String | The id of the record |
callback | function | A callback to execute once the record is retrieved |
Example
retrieve('ContentVersion', '0684K0000020Au7QAE/VersionData');
steps
steps() ⇒ Array
Flattens an array of operations.
Kind: global function
Example
steps(
createIf(params),
update(params)
)
update
update(sObject, attrs) ⇒ Operation
Update an object.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
sObject | String | API name of the sObject. |
attrs | Object | Field attributes for the new object. |
Example
update('obj_name', {
attr1: "foo",
attr2: "bar"
})
upsert
upsert(sObject, externalId, attrs) ⇒ Operation
Upsert an object.
Kind: global function
Access: public
Magic: sObject - $.children[?(!@.meta.system)].name
Magic: externalId - $.children[?(@.name=="{{args.sObject}}")].children[?(@.meta.externalId)].name
Magic: attrs - $.children[?(@.name=="{{args.sObject}}")].children[?(!@.meta.externalId)]
Param | Type | Description |
---|---|---|
sObject | String | API name of the sObject. |
externalId | String | ID. |
attrs | Object | Field attributes for the new object. |
Example
upsert('obj_name', 'ext_id', {
attr1: "foo",
attr2: "bar"
})
upsertIf
upsertIf(logical, sObject, externalId, attrs) ⇒ Operation
Upsert if conditions are met.
Kind: global function
Access: public
Param | Type | Description |
---|---|---|
logical | boolean | a logical statement that will be evaluated. |
sObject | String | API name of the sObject. |
externalId | String | ID. |
attrs | Object | Field attributes for the new object. |
Example
upsertIf(true, 'obj_name', 'ext_id', {
attr1: "foo",
attr2: "bar"
})