Skip to main content

salesforce@4.8.1

bulk(sObject, operation, options, records)
bulkQuery(qs, options, callback)
create(sObject, attrs)
createIf(logical, sObject, attrs)
describe(sObject)
describeAll()
destroy(sObject, attrs, options)
insert(sObject, attrs)
query(qs, options, callback)
reference(position)
relationship(relationshipName, externalId, dataSource)
retrieve(sObject, id, callback)
toUTF8(input)
update(sObject, attrs)
upsert(sObject, externalId, attrs)
upsertIf(logical, sObject, externalId, attrs)

This adaptor exports the following from common:

alterState()
arrayToString()
beta
chunk()
combine()
dataPath()
dataValue()
dateFns
each()
expandReferences()
field()
fields()
fn()
fnIf()
group()
http
humanProper()
index()
join()
jsonValue()
lastReferenceValue()
map()
merge()
referencePath()
scrubEmojis()
source()
sourceValue()
toArray()

Functions

bulk

bulk(sObject, operation, options, records) ⇒ Operation

Create and execute a bulk job.

ParamTypeDefaultDescription
sObjectstringAPI name of the sObject.
operationstringThe bulk operation to be performed.Eg "insert"
optionsobjectOptions passed to the bulk api.
[options.pollTimeout]integer240000Polling timeout in milliseconds.
[options.pollInterval]integer6000Polling interval in milliseconds.
[options.extIdField]stringExternal id field.
[options.failOnError]booleanfalseFail the operation on error.
recordsarrayan array of records, or a function which returns an array.

Example: Bulk insert

bulk(
"Patient__c",
"insert",
{ failOnError: true },
(state) => state.someArray.map((x) => ({ Age__c: x.age, Name: x.name }))
);

Example: Bulk upsert

bulk(
"vera__Beneficiary__c",
"upsert",
{ extIdField: "vera__Result_UID__c" },
[
{
vera__Reporting_Period__c: 2023,
vera__Geographic_Area__c: "Uganda",
"vera__Indicator__r.vera__ExtId__c": 1001,
vera__Result_UID__c: "1001_2023_Uganda",
},
]
);

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. bulkQuery() uses Bulk API v.2.0 Query which is available in API version 47.0 and later. This API is subject to rate limits.

ParamTypeDefaultDescription
qsstringA query string.
optionsobjectOptions passed to the bulk api.
[options.pollTimeout]integer90000Polling timeout in milliseconds.
[options.pollInterval]integer3000Polling 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 }
);

create

create(sObject, attrs) ⇒ Operation

Create a new sObject record(s).

ParamTypeDescription
sObjectstringAPI name of the sObject.
attrsobjectField attributes for the new record.

Example: Single record creation

create("Account", { Name: "My Account #1" });

Example: Multiple records creation

create("Account",[{ Name: "My Account #1" }, { Name: "My Account #2" }]);

createIf

createIf(logical, sObject, attrs) ⇒ Operation

Create a new sObject if conditions are met.

The createIf() function has been deprecated. Use fnIf(condition,create()) instead.

ParamTypeDescription
logicalbooleana logical statement that will be evaluated.
sObjectstringAPI name of the sObject.
attrsobject | Array.<object>Field attributes for the new object.

Example

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

describe

describe(sObject) ⇒ Operation

Prints an sObject metadata and pushes the result to state.references

ParamTypeDescription
sObjectstringAPI name of the sObject.

Example

describe('obj_name')

describeAll

describeAll() ⇒ Operation

Prints the total number of all available sObjects and pushes the result to state.references.

Example

describeAll()

destroy

destroy(sObject, attrs, options) ⇒ Operation

Delete records of an object.

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 })

insert

insert(sObject, attrs) ⇒ Operation

Alias for "create(sObject, attrs)".

ParamTypeDescription
sObjectstringAPI name of the sObject.
attrsobjectField attributes for the new record.

Example: Single record creation

insert("Account", { Name: "My Account #1" });

Example: Multiple records creation

insert("Account",[{ Name: "My Account #1" }, { Name: "My Account #2" }]);

query

query(qs, options, callback) ⇒ 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.

The Salesforce query API is subject to rate limits, See for more details.

ParamTypeDefaultDescription
qsstringA query string. Must be less than 4000 characters in WHERE clause
optionsobjectOptions passed to the bulk api.
[options.autoFetch]booleanfalseFetch next records if available.
callbackfunctionA callback to execute once the record is retrieved

Example

query(state=> `SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.field1}'`);

Example: Query more records if next records are available

query(state=> `SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.field1}'`, { autoFetch: true });

reference

reference(position) ⇒ State

Get a reference ID by an index.

ParamTypeDescription
positionnumberPosition for references array.

Example

reference(0)

relationship

relationship(relationshipName, externalId, dataSource) ⇒ object

Adds a lookup relation or 'dome insert' to a record.

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).

ParamTypeDescription
sObjectstringThe sObject to retrieve
idstringThe id of the record
callbackfunctionA callback to execute once the record is retrieved

Example

retrieve('ContentVersion', '0684K0000020Au7QAE/VersionData');

toUTF8

toUTF8(input) ⇒ string

Transliterates unicode characters to their best ASCII representation

Returns: string - - ASCII representation of input string

ParamTypeDescription
inputstringA string with unicode characters

Example

fn((state) => {
const s = toUTF8("άνθρωποι");
console.log(s); // anthropoi
return state;
});

update

update(sObject, attrs) ⇒ Operation

Update an sObject record or records.

ParamTypeDescription
sObjectstringAPI name of the sObject.
attrsobject | Array.<object>Field attributes for the new object.

Example: Single record update

update("Account", {
Id: "0010500000fxbcuAAA",
Name: "Updated Account #1",
});

Example: Multiple records update

update("Account", [
{ Id: "0010500000fxbcuAAA", Name: "Updated Account #1" },
{ Id: "0010500000fxbcvAAA", Name: "Updated Account #2" },
]);

upsert

upsert(sObject, externalId, attrs) ⇒ Operation

Create a new sObject record, or updates it if it already exists External ID field name must be specified in second argument.

ParamTypeDescription
sObjectstringAPI name of the sObject.
externalIdstringThe external ID of the sObject.
attrsobject | Array.<object>Field attributes for the new object.

Example: Single record upsert

upsert("UpsertTable__c", "ExtId__c", { Name: "Record #1", ExtId__c : 'ID-0000001' });

Example: Multiple record upsert

upsert("UpsertTable__c", "ExtId__c", [
{ Name: "Record #1", ExtId__c : 'ID-0000001' },
{ Name: "Record #2", ExtId__c : 'ID-0000002' },
]);

upsertIf

upsertIf(logical, sObject, externalId, attrs) ⇒ Operation

Conditionally create a new sObject record, or updates it if it already exists

The upsertIf() function has been deprecated. Use fnIf(condition,upsert()) instead.

ParamTypeDescription
logicalbooleana logical statement that will be evaluated.
sObjectstringAPI name of the sObject.
externalIdstringID.
attrsobject | Array.<object>Field attributes for the new object.

Example

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