Skip to main content

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

ParamTypeDescription
sObjectStringAPI name of the sObject.
operationStringThe bulk operation to be performed
optionsObjectOptions passed to the bulk api.
funfunctionA 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

ParamTypeDescription
qsStringA query string.
optionsObjectOptions passed to the bulk api.
[options.pollTimeout]integerPolling timeout in milliseconds.
[options.pollInterval]integerPolling interval in milliseconds.
callbackfunctionA 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

ParamType
stateState

Example

cleanupState(state)

create

create(sObject, attrs) ⇒ Operation Create a new object.

Kind: global function
Access: public

ParamTypeDescription
sObjectStringAPI name of the sObject.
attrsObjectField attributes for the new object.

Example

create('obj_name', {
attr1: "foo",
attr2: "bar"
})

createConnection

createConnection(state) ⇒ State Creates a connection.

Kind: global function

ParamTypeDescription
stateStateRuntime state.

Example

createConnection(state)

createIf

createIf(logical, sObject, attrs) ⇒ Operation Create a new object if conditions are met.

Kind: global function
Access: public

ParamTypeDescription
logicalbooleana logical statement that will be evaluated.
sObjectStringAPI name of the sObject.
attrsObjectField 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

ParamTypeDescription
sObjectStringAPI 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

ParamTypeDescription
sObjectStringAPI name of the sObject.
attrsObjectArray of IDs of records to delete.
optionsObjectOptions for the destroy delete operation.

Example

destroy('obj_name', [
'0060n00000JQWHYAA5',
'0090n00000JQEWHYAA5
], { failOnError: true })

execute

execute(operations) ⇒ State Executes an operation.

Kind: global function

ParamTypeDescription
operationsOperationOperations

login

login(state) ⇒ State Performs a login.

Kind: global function

ParamTypeDescription
stateStateRuntime 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

ParamTypeDescription
qsStringA 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

ParamTypeDescription
positionnumberPosition 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

ParamTypeDescription
relationshipNamestring__r relationship field on the record.
externalIdstringSalesforce ExternalID field.
dataSourcestringresolvable 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

ParamTypeDescription
sObjectStringThe sObject to retrieve
idStringThe id of the record
callbackfunctionA 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

ParamTypeDescription
sObjectStringAPI name of the sObject.
attrsObjectField 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)]

ParamTypeDescription
sObjectStringAPI name of the sObject.
externalIdStringID.
attrsObjectField 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

ParamTypeDescription
logicalbooleana logical statement that will be evaluated.
sObjectStringAPI name of the sObject.
externalIdStringID.
attrsObjectField attributes for the new object.

Example

upsertIf(true, 'obj_name', 'ext_id', {
attr1: "foo",
attr2: "bar"
})