Use Bulk API to update Salesforce records
Insert/Update/Delete Salesforce records using the Bulk API and a SOQL query.
Optionally use anonymous apex to provide additional context.
The SOQL query is used to generate the input. Each record returned by the
query is made available to the Expr expression as a map named "record". See
https://expr.medv.io/ for details on the Expr language. The expression should
evaluate to an map of the form, "{ Field: Value, ... }" or an array of such
maps.
In addition to Expr's built-in operators and functions, the following
functions can be used within the expression:
- stripHtml: removes HTML tags
- escapeHtml: escapes characters using HTML entities like Apex's
String.escapeHtml4 method
- escapeUnicode: escapes characters using Unicode escape sequences
like Apex's String.escapeUnicode method
- base64: base-64 encodes input
- md5: md5 hash of string
- getSet: set key to value, returning previous value for key
- compareAndSet: check if key maps to value; if key doesn't exist, set it to
value (return true unless key already exists with different value)
- changeValue: update value associated with key (returns true unless the key
already exists and the value is unchanged)
- incr: increments the number stored at key by one. set to 1 if not set.
- clone: create a copy of the record
The + and - operators can be used to add, update, or remove fields on the
record object. For example:
record + {RecordTypeId: apex.myRecordTypeId} - "RecordType.Name"
If creating multiple records from a source record, use clone to avoid mutating
the same object repeatedly. For example:
1..100 | map(clone(record) + {Name: "Record " + string(#)})
Additional context to be provided to the Expr expression by passing the
--context parameter containining anonymous apex to execute before the
records are queried. Each apex variable defined will be available within
the "apex" map.
A csv file can be used as input instead of a SOQL query by using the --file
parameter. This is often useful when combined with --apex to map input to
org-specific values such as Record Type Ids.
batchforce
-a, --account username account username to use
-h, --help help for batchforce
--quiet suppress informational log messages
- batchforce delete - delete Salesforce records using the Bulk API
- batchforce insert - insert Salesforce records using the Bulk API
- batchforce update - Update Salesforce records using the Bulk API
- batchforce upsert - upsert Salesforce records using the Bulk API
- batchforce version - Display current version