Single-record sObject CRUD, external-id upserts, and describe. For up to 200 records per call see ::salesforce::composite; for more, ::salesforce::bulk.
Functions
create-record
fn (sobject-type: Str, fields: Map): Map
fn (sobject-type: Str, fields: Map, opts: Map): Map
POST /sobjects/{type} - Create a record. Returns {id, success, errors}.
Example
lead ::salesforce::sobjects/create-record("Lead", {LastName: "Lovelace", Company: "AE"})
lead.id
delete-record
fn (sobject-type: Str, id: Str): Any
fn (sobject-type: Str, id: Str, opts: Map): Any
DELETE /sobjects/{type}/{id} - Delete a record (it goes to the recycle bin). Returns null on success.
Example
::salesforce::sobjects/delete-record("Lead", "00Q000000000001")
describe-global
fn (): Map
fn (opts: Map): Map
GET /sobjects - Every object in the org (sobjects: name, label,
custom, queryable, createable, ...) plus maxBatchSize.
Example
global ::salesforce::sobjects/describe-global()
map(filter(global.sobjects, (o) { o.custom }), (o) { o.name })
describe-object
fn (sobject-type: Str): Map
fn (sobject-type: Str, opts: Map): Map
GET /sobjects/{type}/describe - The object's full schema: fields
(name, type, length, picklistValues, referenceTo, nillable,
createable, updateable, externalId), childRelationships,
and recordTypeInfos.
Example
schema ::salesforce::sobjects/describe-object("Opportunity")
stage first(filter(schema.fields, (f) { eq(f.name, "StageName") }))
map(stage.picklistValues, (p) { p.value })
field-names
fn (description: Map): Vec
The field API names from a describe-object result. Handy for building
SELECT lists.
Example
::salesforce::sobjects/field-names({fields: [{name: "Id"}, {name: "Email"}]}) // ["Id", "Email"]
get-by-external-id
fn (sobject-type: Str, external-id-field: Str, value: Any): Map
fn (sobject-type: Str, external-id-field: Str, value: Any, opts: Map): Map
fn (sobject-type: Str, external-id-field: Str, value: Any, fields: Vec): Map
fn (sobject-type: Str, external-id-field: Str, value: Any, fields: Vec, opts: Map): Map
GET /sobjects/{type}/{externalIdField}/{value} - Fetch a record by an
external id field; the 4-arity form limits the returned fields.
Example
contact ::salesforce::sobjects/get-by-external-id("Contact", "External_Id__c", "u-42", ["Id", "Email"])
contact.Id
get-record
fn (sobject-type: Str, id: Str): Map
fn (sobject-type: Str, id: Str, opts: Map): Map
fn (sobject-type: Str, id: Str, fields: Vec): Map
fn (sobject-type: Str, id: Str, fields: Vec, opts: Map): Map
GET /sobjects/{type}/{id} - One record; the 3-arity form limits the
returned fields (Vec of API names).
Example
lead ::salesforce::sobjects/get-record("Lead", "00Q000000000001", ["Name", "Email"])
lead.Email
record-path
fn (sobject-type: Str): Str
fn (sobject-type: Str, id: Str): Str
fn (sobject-type: Str, external-id-field: Str, value: Any): Str
/sobjects/{type}, plus /{id} segments when given, each URL-encoded.
Exposed for testing.
Example
::salesforce::sobjects/record-path("Lead") // "/sobjects/Lead"
::salesforce::sobjects/record-path("Lead", "00Q1") // "/sobjects/Lead/00Q1"
::salesforce::sobjects/record-path("Contact", "External_Id__c", "u-42") // "/sobjects/Contact/External_Id__c/u-42"
update-record
fn (sobject-type: Str, id: Str, fields: Map): Any
fn (sobject-type: Str, id: Str, fields: Map, opts: Map): Any
PATCH /sobjects/{type}/{id} - Update the given fields; others are untouched. Salesforce replies 204: returns null on success.
Example
::salesforce::sobjects/update-record("Lead", "00Q000000000001", {Status: "Working"})
upsert-record
fn (sobject-type: Str, external-id-field: Str, value: Any, fields: Map): Map
fn (sobject-type: Str, external-id-field: Str, value: Any, fields: Map, opts: Map): Map
PATCH /sobjects/{type}/{externalIdField}/{value} - Create or update
by external id: the idempotent way to sync records in. Returns
{id, success, errors, created} (created is true for an insert).
Use Id as the field to update by record id. More than one match is
a 300 Err listing the candidates.
Example
out ::salesforce::sobjects/upsert-record("Contact", "External_Id__c", "u-42", {LastName: "Lovelace"})
out.created