sfio
v0.0.15
Published
Stream CSV data in and out of Salesforce
Downloads
3
Readme
sfio
Stream CSV data in and out of Salesforce.
sfio uses the new Bulk API 2.0 for insert, update, upsert, and delete. https://developer.salesforce.com/docs/atlas.en-us.api_bulk_v2.meta/api_bulk_v2/introduction_bulk_api_2.htm
sfio uses the old Bulk API for query because the new one doesn't support query (yet, maybe never will).
Get Started
See https://github.com/Candoris/sfio-starter for a quick start template project.
No More Lookup Maps!!!
One of the big reasons we moved to the new bulk api 2.0 is the relationship feature.
In the example below, we can use an external id field on Account to link the contact to the account. This is much more convenient than having somehow lookup the account's Salesforce Id.
FirstName,LastName,Account.SomeExternalId__c
Tom,Jones,293483
https://developer.salesforce.com/docs/atlas.en-us.api_bulk_v2.meta/api_bulk_v2/datafiles_csv_rel_field_header_row.htm
Install
npm i -g git+ssh://[email protected]:Candoris/sfio.git
Enjoy
For help type a command without any argument.
poll
waits till the job in Salesforce has completed successfully or failed
before returning. On error, we exit with a non-zero (error) code.
sf-query SOQL [pkChunking] [queryAll] > some.csv
sf-insert OBJECT [poll] < some.csv
sf-update OBJECT [poll] < some.csv
sf-upsert OBJECT ID_COLUMN [poll] < some.csv
sf-delete OBJECT [poll] < some.csv
sf-info JOB_ID > some.json
sf-failed JOB_ID [plain] > some.csv
sf-unprocessed JOB_ID > some.csv
sf-success JOB_ID > some.csv
Configure
sfio looks for a file named sfio-config.js
in the current directory. This file
should not contain any secrets. It should simply point to the actual config file
which should be located in the folder one level above your project folder and
be named something that tells us which customer it is.
./sfio-config.js
exports = module.exports = require('../sfio-my-customer.js');
The real config file will contain both source and destination information because you may be querying from one Salesforce organization and updating another. It also will contain secrets which must be secret and never checked into git.
~/my-configs/sfio-my-customer.js
exports = module.exports = {
source: {
url: 'https://login.salesforce.com',
username: '[email protected]',
password: '***',
token: '***',
apiVersion: '41.0',
consumerKey: '3MV***xu4',
consumerSecret: '694***048'
},
dest: {
url: 'https://login.salesforce.com',
username: '[email protected]',
password: '***',
token: '***',
apiVersion: '41.0',
consumerKey: '3MV***xu4',
consumerSecret: '694***048'
}
};
// exports = module.exports = {
// source: {
// url: 'https://test.salesforce.com',
// username: '[email protected]',
// password: '***',
// token: '***',
// apiVersion: '41.0',
// consumerKey: '3MV***xu4',
// consumerSecret: '694***048'
// },
// dest: {
// url: 'https://test.salesforce.com',
// username: '[email protected]',
// password: '***',
// token: '***',
// apiVersion: '41.0',
// consumerKey: '3MV***xu4',
// consumerSecret: '694***048'
// }
// };