Example Site
To see a live example, click here.
The Salesforce Integration package provides you with the ability to easily monitor and manage data records in your Salesforce account from a Wix site. You can perform the following actions with this package:
To see an example site that demonstrates how to use this package, click here.
Before using the package, set up the following:
Open the Wix Secrets Manager and create a new secret with the name velo-salesforce-credentials
. Store the following JSON object in the secret:
Note: Make sure that the object is in correct JSON format, including all quotes. If not, the Secrets Manager will not be able to read the object properly, resulting in incorrect Salesforce credentials.
The following backend files are included in the package. Note that only exported functions that you can use in your site are listed here.
The code in this file contains functions for querying, retrieving, creating, updating, and deleting data records from Salesforce.
To use the functions below in your backend code, import them with the following syntax:
The file contains the following functions:
queryRecords()
Queries a Salesforce object using an SOQL command and returns the data records that match the criteria specified in the command.
retrieveRecords()
Retrieves data records with the specified IDs from a Salesforce object.
Note that you can only use this function when you know the IDs of the records you want to retrieve in advance. Use the queryRecords()
function instead to get the records when you don’t know the IDs, or to specify other selection criteria.
createRecords()
Creates one or more records of a specific Salesforce object.
updateRecords()
Updates specified data records in a specific Salesforce object.
deleteRecords()
Deletes specified data records in a specific Salesforce object with the specified IDs.
sfObjName
: Name of the Salesforce object (for example, Account
). See the list of all Salesforce objects here.queryStr
: An SOQL command specifying what to query.ids
: Array of record IDs for a Salesforce object. Each instance of a Salesforce object is called a record.records
: Single or array of record objects. Each instance of a Salesforce object is called a record.This section demonstrates how you can work with the package, and the different options for using the package functions.
The following describes how you can use this package to add a new Salesforce object instance (record). In our example, we demonstrate how to create a new Account object record, but you can use the code to create one or more records for any Salesforce object type. In our example, we create the record with the Name
and Phone
fields, but you can adapt the code to create records with any fields. .
To use the createRecords()
function in your page code, add a web module to your backend. We’ll call ours salesforce-wrapper.jsw. Include the following code in this file:
Add the following page elements to your site:
Import the createRecordsWrapper()
function from the web module to your page code and run it when the button is clicked. Call the createRecordsWrapper()
function to create the record with data from the input elements.
The following describes how you can use this package to query a phone number from a specific Account record (Salesforce object) based on the record name. If you want to query a different field or a different Salesforce object type, simply adapt the code for your use case.
To use the queryRecords()
function in your page code, add a web module to your backend. We’ll call ours salesforce-wrapper.jsw. Include the following code in this file:
Add the following page elements to your site:
Import the getPhoneBasedOnName()
function from the web module to your page code and run it when the button is clicked to query the records.
This Velo package uses the following npm package. To view the npm license, see the npm readme.
1.0 Initial version.
salesforce, jsforce, sales