The Vlocity Software Development Toolkit (SDK) is a collection of Vanilla JavaScript SDKs that are designed to interact with Vlocity's product capabilities. The SDKs are packaged for different industrial applications and are version specific. For example, if you have installed the CME ** package in your Salesforce org, you will use the corresponding CME ** SDKs.
Key features of SDKs:
The Datasource SDK provides convenient functions to access Salesforce, Vlocity and generic REST APIs including SOQL, SOSL, Apex REST, Apex Remote, Vlocity DataRaptor, Integration Procedure, and REST.
The Translation SDK provides translations for labels via Salesforce custom labels.
The Account SDK provides Vlocity account-based contracts, assets and intelligent offer capabilities.
The Digital Commerce SDK provides the ability to retrieve offers, offer validation and cart operation capabilities.
The Pub Sub SDK provides the ability to publish and subscribe events across different UI components.
The CPQ SDK provides the ability to call all cart based V2 API's.
The B2B Express SDK provides the ability to call all cart based V2 API's and express VIP & DR's.
All SDKs are singletons. This means there is (and should only be) one instance of the SDK in the application you are building. Having only one instance ensures the states stored in the SDK are shared across different UI components in the application, and also eliminates the consumption of memory for multiple SDK instances.
First, create an SDK configuration object or use SDK function to create a default configuration object if provided. Then, retrieve an instance with the SDK configuration object.
const datasourceSDKConfig = {
sessionId: "SalesforceSessionId";
useApexRemoteForDualDataSource: true;
};
const datasource = VlocitySDK.datasource.getInstance(datasourceSDKConfig);
const soqlInput = { query: "select id from Account" };
datasource.soql(soqlInput).execute().then(result => {
// do something with result
});
All of the Vlocity SDKs allows developers to override and extend out-of-the-box functions.
const datasourceSDKExtension = {
stream() {
// return readable Node stream;
},
poll() {
return "add poll function";
}
};
DataSource.extend(datasourceSDKExtension);
const datasource = DataSource.getInstance(config);
// using SDK extension
datasource.stream().on('data', (chunk) => {...});
SDKs use Semantic Versioning to define SDK version in the form of "MAJOR.MINOR.PATCH". SDKs provides matching functionalities that are available in the matching packages.
const datasource = VlocitySDK.datasource.getInstance(datasourceSDKConfig);
datasource.version();// return datasource version
Vlocity SDKs are distributed inside Vlocity packages as well as via our NPM registry.
In Vlocity package is a static resource - vlocitysdk. Developers can use this static resources inside Visualforce pages to load the necessary SDKs.
<script src="{!URLFOR($Resource.vlocitysdk, 'latest/datasource/datasource.sdk.js')}"></script>
Vlocity SDKs are available on the Vlocity protected npm registry. Similar to any UI development, you can add and load the Vlocity SDK dependency. You will need npm and NodeJS LTS installed on your local development machine.
.npmrc
email=<email>
always-auth=true
_auth=<authToken>
registry=https://repo.vlocity.com/repository/npm-public/
package.json
"dependencies": {
...
"@vlocity-cme-sdk/datasource-sdk": "107.1.0",
"@vlocity-cme-sdk/digitalcommerce-sdk": "107.1.0",
"@vlocity-cme-sdk/translation-sdk": "107.1.0"
...
},
npm install
To simplify UI development, Vlocity has created a partner development bootstrap project with SDK npm dependency preconfigured. There are sample applications that show how to use various SDK functionalities. To get access to our bootstrap project, please file a request with your account representative.
Generated using TypeDoc