Skip to main content

Developer README for the salesforce adaptor

Source: https://github.com/OpenFn/adaptors/tree/main/packages/salesforce

Language Salesforce

Salesforce Language Pack for OpenFn. See the main docs site: http://openfn.github.io/language-salesforce/

Release notes and deprecated CHANGELOG.md

See releases for all changes.

Sample configuration

{
"loginUrl": "https://somesalesforcelogin.url/",
"username": "someusername",
"password": "somesupersecretpassword",
"securityToken": "salesforcesecuritytoken"
}

Intent


Allow communication with Salesforce using a set of Lisp compatible expressions.

Using simple functions we can create a simplified API, simple enough to generate code from data.

Expressions


Expressions are a simplified set of function calls. Outlining the operations needed to be performed.

An uncompiled expression has no knowledge of the internals of the adaptor, credentials or runtime environment.

It's the responsibility of the build process to provide a wrapper that will inject the functions in.

For example:

describe('vera__Test_Event__c'),
create('vera__Test_Event__c', {
vera__Test_Event_Name_Unique__c: 'hello from jsforce',
}),
create('vera__Boat__c', {
Name: 'Catatafish redux!',
vera__Test_Event__c: reference(0),
});

## API

field("key","value") Returns { "key": "value" }

relationship("relationship_name__r", "externalID", dataSource("path"))

describe("obj_name")

query('queryString')

bulk('obj_name', 'operation', 'options', arrayOfFields)

create('obj_name', fields())

destroy('obj_name', fields())

createIf(logical, 'obj_name', fields())

upsert(sObject, 'externalID', fields())

upsertIf(logical, 'obj_name', 'externalID', fields())

update('obj_name', fields())

Development

Clone the adaptors monorepo. Follow the Getting Started guide inside to get set up.

Run tests using pnpm run test or pnpm run test:watch

Build the project using pnpm build.

To just build the docs run pnpm build docs

## Other

Create SOAP session

curl https://test.salesforce.com/services/Soap/u/47.0 -H "Content-Type: text/xml; charset=UTF-8" -H "SOAPAction: login" -d @tmp/login.txt | xmllint --format -

Close jobs

curl
https://openfn.my.salesforce.com/services/async/47.0/job/some_id -H 'X-SFDC-Session: abc123sessionID456xyz' -H "Content-Type: application/xml; charset=UTF-8" -d @tmp/close_job.txt | xmllint --format -