Synopsis
soap_salesforce is a library that facilitates login into Salesforce SOAP API, and provide basic functionality for calling most used Salesforce API methods. Specifically it is designed to be used with an Enterprise WSDL, but it can be easily adapted in order to use other kind of Salesforce WSDL files.
Short "how to use" guide is available (here).
Code Example
Initializing and querying Salesforce
//We will require soap_salesforce in order to call Salesforce SOAP API.var salesforce = ;//Create an instance of soap_salesforce.var salesforceAPI = "username""password""token""enterprise wsdl xml path";//Now, login to the API, it will return us a promise. salesforceAPI;
Using helper methods
soap_salesforce provide two useful methods in addition to the methods we have already seen: One for escaping characters in a SOQL sentence, and other for formatting a javascript object in order to pass it as a parameter when creating or editing Salesforce records.
Escaping SOQL parameters
var accountName = "Escape ' me % please _"; //Unescaped parameteraccountName = salesforceAPI; //Escaped parameter.var query = salesforceAPI; soapClient;
Creating or editing a record
//Define new account datavar newAccount = Name: "Fake account" Description__c: "Another field here :)" ;//Format it into an sObjectvar newAccount = salesforceAPI; //Now we can create the recordsoapClient;
Installation
NPM is required for installing this library.
In order to install, open a terminal, place in your project's folder, and type npm install soap_salesforce
.
Contributors
- Oriol Egea (@OriolEgea)
License
Released under AGPL-V3.