Package Exports
- sage-live
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sage-live) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Installation
npm install sage-live --save
Overview
- Handles Authentication
- Allows Bulk Inserting, Upserting, Getting of all Salesforce objects that underpin Sage Live
- Returns Promises
The sage-live package is an easy way to deal with the revel API when using node.
var SageLive = require('sage-live');
var verbose = true;
var endpoint = 'https://salesforce.com';
var userName = 'kristo.mikkonen@fabacus.com';
var password = 'PasswordHere';
var securityToken = 'asdasdasdasdsad';
var sageLive = new SageLive(endpoint, userName, password, securityToken, verbose);
// Retrive objects by ID
sageLive.retrieve("Account", ["0015800000RTgER", "0015800000RTgTH"]).then((result) => {
console.log(typeof(result));
})
If you want to interact with a different object, for example products with a resource URL of: "/resources/Product/" the function would be getProduct()
or if you want to access an order item at "/resources/OrderItem/" the function would be getOrderItem()
.
A full list of all the functions can be found at the bottom of this readme.
Example Usage:
var SageLive = require('sage-live');
var verbose = true;
var endpoint = 'https://salesforce.com';
var userName = 'kristo.mikkonen@fabacus.com';
var password = 'PasswordHere';
var securityToken = 'asdasdasdasdsad'; // optional
var sageLive = new SageLive(endpoint, userName, password, securityToken, verbose);
Retrive and Delete by ID
// Retrieve the following 2 accounts
sageLive.retrive("Account", ["0015800000RTkYH", "0015800000RTkYF"]).then((result) => {
console.log(result);
}).catch((err) => {
console.log(err);
})
// Delete the following account
sageLive.delete("Account", ["0015800000RTkYH"]).then((result) => {
console.log(result);
}).catch((err) => {
console.log(err);
})
Search
// Get multiple objects using search options
salesforceObject = "Account";
var searchOptions = {
CreatedDate: {
$gte: sageLive.date.LAST_N_WEEKS(2)
},
}
sortingOptions = {
CreatedDate: -1,
}
limit = 0;
skip = 0
sageLive.get(salesforceObject, searchOptions, sortingOptions, limit, skip).then((result) => {
for(var i = result.length - 1; i >= 0; i--) {
console.log(result[i].Name);
}
}).catch((err) => {
console.log(err);
})
Bulk Insert
const itemsForBulkInsert = [{
Name: 'Patrick McKinley',
}, {
Name: 'Kristo Mikkonen',
}
]
// Bulk insert into Account object
sageLive.bulkInsert("Account", itemsForBulkUpsert).then((result) => {
console.log(result);
}).catch((err) => {
console.log(err);
})
#Bulk Upsert
const itemsForBulkUpsert = [{
Name: 'Patrick McKinley',
Id: '0015800000RTkYH'
}, {
Name: 'Kristo Mikkonen',
Id: '0015800000RTkY2'
}
]
const externalId = {
extIdField: 'Id'
}
// Bulk upsert into Account object using the Id as the key
sageLive.bulkUpsert("Account", externalId, itemsForBulkUpsert).then((result) => {
console.log(result);
}).catch((err) => {
console.log(err);
})