![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@bolomio/salesforce-connector
Advanced tools
The @bolomio/salesforce-connector
package provides a connector that allows you to interact with the standard Salesforce API. It offers functions for creating records, executing SOQL and SOSL queries, and more.
You can install the package using npm:
npm install @bolomio/salesforce-connector
To use the Salesforce Connector, you need to create an instance of it by calling the makeSalesforceConnector
function with the required configurations.
const { makeSalesforceConnector } = require('@bolomio/salesforce-connector')
// Create the Salesforce Connector instance
const connector = makeSalesforceConnector({
baseUrl: 'https://your-salesforce-instance.com/',
accessToken: 'your_access_token',
})
To authorize your requests, you have multiple options:
const { makeSalesforceConnector } = require('@bolomio/salesforce-connector')
// Create the Salesforce Connector instance
const connector = makeSalesforceConnector({
baseUrl: 'https://your-salesforce-instance.com/',
accessToken: 'your_access_token',
})
beforeRequest
hook.const { makeSalesforceConnector } = require('@bolomio/salesforce-connector')
// Create the Salesforce Connector instance
const connector = makeSalesforceConnector({
baseUrl: 'https://your-salesforce-instance.com/',
hooks: {
beforeRequest: [
(options) => {
console.log('Setting token')
options.headers['Authorization'] = 'Bearer {your_access_token}'
},
],
},
})
Make sure to replace 'https://your-salesforce-instance.com/'
with the actual Salesforce instance URL and 'your_access_token'
with the valid access token obtained through a secure authentication process.
Note: to receive an access token you can use the @bolomio/salesforce-authorizer
Executes a collection of standard api requests
async function compositeExample() {
try {
const result = await connector.composite({
allOrNone: true,
compositeRequest: [
connector.compositeRequests.soqlQuery({
referenceId: 'reference_id_account_1',
queryStatement: 'SELECT Id FROM Account LIMIT 1',
}),
connector.compositeRequests.createSObject({
record: {
LastName: 'Koko',
AccountId: '@{reference_id_account_1.records[0].Id}',
},
sObjectName: 'Contact',
referenceId: 'reference_id_contact_1',
}),
],
})
console.log('1 composite executed successfully:', result.compositeResponse[0])
console.log('2 composite executed successfully:', result.compositeResponse[1])
} catch (error) {
console.error('Error executing composite:', error)
}
}
compositeExample()
Create a new record of a specific Salesforce object using the provided data.
async function createSObjectExample() {
const sObjectName = 'Account'
const record = {
Name: 'Acme Corporation',
Industry: 'Technology',
}
try {
const result = await connector.createSObject({ sObjectName, record })
console.log('Record created successfully:', result)
} catch (error) {
console.error('Error creating record:', error)
}
}
createSObjectExample()
Update a record of a specific Salesforce object using the provided data.
async function updateSObjectExample() {
const sObjectName = 'Account'
const recordId = '0011t00000B0lOMAAZ'
const record = {
Name: 'Acme Corporation',
Industry: 'Technology',
}
try {
await connector.updateSObject({ sObjectName, recordId, record })
console.log('Record updated successfully')
} catch (error) {
console.error('Error updating record:', error)
}
}
updateSObjectExample()
Insert or Update (Upsert) a Record Using an External ID.
async function upsertSObjectByExternalIdExample() {
const sObjectName = 'Account'
const sObjectFieldName = 'AccountExternalId__c'
const externalId = 'Account-123'
const record = {
Name: 'Acme Corporation',
Industry: 'Technology',
}
try {
const result = await connector.upsertSObjectByExternalId({ sObjectName, sObjectFieldName, externalId, record })
console.log('Record upserted successfully:', result)
} catch (error) {
console.error('Error upserting record:', error)
}
}
upsertSObjectByExternalIdExample()
Execute a SOQL (Salesforce Object Query Language) query and retrieve the results.
async function soqlQueryExample() {
const queryStatement = 'SELECT Id, Name, Industry FROM Account WHERE Industry = \'Technology\''
try {
const result = await connector.soqlQuery({ queryStatement })
console.log('Query results:', result)
} catch (error) {
console.error('Error executing SOQL query:', error)
}
}
soqlQueryExample()
Execute a SOSL (Salesforce Object Search Language) query and retrieve the results.
async function soslQueryExample() {
const queryConfiguration: {
q: '00001',
in: 'PHONE',
fields: ['Name'],
sobjects: [{ name: 'Contact' }],
}
try {
const result = await connector.soslQuery({ queryConfiguration })
console.log('Query results:', result)
} catch (error) {
console.error('Error executing SOSL query:', error)
}
}
soslQueryExample()
Execute a http request against a custom apex rest endpoint. Salesforce Documentation
Get Example
async function apexRestGetExample() {
const companyId = 'bolo-id'
try {
const result = await connector.apexRest({
method: 'GET',
requestURI: `/bolo-companies/${companyId}`,
})
console.log('Get result:', result)
} catch (error) {
console.error('Error executing get request: ', error)
}
}
apexRestGetExample()
Put Example
async function apexRestPutExample() {
const companyId = 'bolo-id'
// the json body to be used in the request
const json = {
name: 'bolo'
}
try {
const result = await connector.apexRest({
method: 'PUT',
requestURI: `/bolo-companies/${companyId}`,
json
})
console.log('Put result:', result)
} catch (error) {
console.error('Error executing put request: ', error)
}
}
apexRestPutExample()
Post Example with no content response
async function apexRestPostWithNoContentResponseExample() {
// the json body to be used in the request
const json = {
name: 'bolo'
}
try {
await connector.apexRest({
method: 'POST',
requestURI: `/bolo-companies/`,
json
})
} catch (error) {
console.error('Error executing post request: ', error)
}
}
apexRestPostWithNoContentResponseExample()
Execute an http request against the Knowledge Article API to list articles. Salesforce Documentation
Get Knowledge Articles List Example
async function getKnowledgeArticlesListExample() {
const language = 'en-US'
try {
const result = await connector.getKnowledgeArticlesList({
language,
queryParams: {
sort: 'ViewScore',
channel: 'Pkb',
pageSize: 10,
}
})
console.log('Knowledge result:', result)
} catch (error) {
console.error('Error executing get request: ', error)
}
}
Other features will be added that use the standard salesforce api:
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request. Make sure to follow the contribution guidelines.
This project is licensed under the GNU General Public License.
FAQs
functions to interact with the standard salesforce api
We found that @bolomio/salesforce-connector demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.