Releases: OpenFn/language-salesforce
bulk can return noOp with empty array
Pass the allowNoOp: true
option to bulk, and it will skip attempting to perform a bulk operation if your function returns an empty array of records to operate on.
bulk('Financial__c', 'upsert', { extIdField: 'Unique_ID__c', failOnError: true, allowNoOp: true }, state => {
return [];
});
// The above will result in:
// $ No items in Financial__c array. Skipping bulk upsert operation.
SOQL Queries and Bulk API operations
The result of the SOQL query gets put into references[0], just like the other Salesforce responses. It can then be used for later operations in the same job.
query(`SELECT Id FROM Patient__c WHERE Health_ID__c = '${state.data.field1}'`);
Add the failOnError
option to a bulk operation if you want the job to be marked as a failure if any of the individual record actions fails.
bulk('Patient__c', 'insert', { failOnError: true }, state => {
return state.data.someArray.map(item => {
return { 'Age__c': item.age, 'Name': item.name }
})
});
humanProper
import humanProper from language-common for converting underscored lower case text like this_text_here
to proper-cased and spaced text like This Text Here
.
documentation updated
state is passed in automatically by execute
and expandReferences
documentation!
v0.5.0 bump version to 0.5.0
Conditional create and upsert
createIf(logical, object, fields)
upsertIf(logical, object, externalId, fields)
added `update(...)` function
v0.3.0 added update(...) function in v0.3.0
added alterState from language-common
Users can now alterState
before or during other operations.
https://github.com/OpenFn/language-common/blob/master/src/index.js#L29-L40