salesforce@4.8.6
- 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.
Param | Type | Default | Description |
---|---|---|---|
sObject | string | API name of the sObject. | |
operation | string | The bulk operation to be performed.Eg "insert" | |
options | object | Options passed to the bulk api. | |
[options.pollTimeout] | integer | 240000 | Polling timeout in milliseconds. |
[options.pollInterval] | integer | 6000 | Polling interval in milliseconds. |
[options.extIdField] | string | External id field. | |
[options.failOnError] | boolean | false | Fail the operation on error. |
records | array | an 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.
Param | Type | Default | Description |
---|---|---|---|
qs | string | A query string. | |
options | object | Options passed to the bulk api. | |
[options.pollTimeout] | integer | 90000 | Polling timeout in milliseconds. |
[options.pollInterval] | integer | 3000 | 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 }
);
create
create(sObject, attrs) ⇒ Operation
Create a new sObject record(s).
Param | Type | Description |
---|---|---|
sObject | string | API name of the sObject. |
attrs | object | Field 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.
Param | Type | Description |
---|---|---|
logical | boolean | a logical statement that will be evaluated. |
sObject | string | API name of the sObject. |
attrs | object | 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
Param | Type | Description |
---|---|---|
sObject | string | API 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.
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 })
insert
insert(sObject, attrs) ⇒ Operation
Alias for "create(sObject, attrs)".
Param | Type | Description |
---|---|---|
sObject | string | API name of the sObject. |
attrs | object | Field 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.
Param | Type | Default | Description |
---|---|---|---|
qs | string | A query string. Must be less than 4000 characters in WHERE clause | |
options | object | Options passed to the bulk api. | |
[options.autoFetch] | boolean | false | Fetch next records if available. |
callback | function | A 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.
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.
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).
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');
toUTF8
toUTF8(input) ⇒ string
Transliterates unicode characters to their best ASCII representation
Returns: string
- - ASCII representation of input string
Param | Type | Description |
---|---|---|
input | string | A 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.
Param | Type | Description |
---|---|---|
sObject | string | API name of the sObject. |
attrs | object | 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.
Param | Type | Description |
---|---|---|
sObject | string | API name of the sObject. |
externalId | string | The external ID of the sObject. |
attrs | object | 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.
Param | Type | Description |
---|---|---|
logical | boolean | a logical statement that will be evaluated. |
sObject | string | API name of the sObject. |
externalId | string | ID. |
attrs | object | Array.<object> | Field attributes for the new object. |
Example
upsertIf(true, 'obj_name', 'ext_id', {
attr1: "foo",
attr2: "bar"
})