Loading...

CRM developers typically need to integrate Salesforce with Node.js apps. One well-known library for this purpose is jsForce, which provides a comprehensive set of tools for interacting with Salesforce data and performing CRUD tasks effectively.

Let’s dive into the blog, where you will understand the use of jsForce to execute key CRUD tasks within Salesforce, as well as how to make the most of the Composite API to handle multiple actions in one request. Whether you’re new to Salesforce development or an experienced developer, this guide will help you seamlessly integrate Salesforce into your Node.js apps.

Seamless Salesforce API Integration with jsForce

jsForce is a well-known open-source JavaScript library that empowers developers to communicate with various Salesforce APIs, such as REST, Bulk, and Metadata APIs. With jsForce, users can handle Salesforce records, run SOQL queries, and interact with objects directly from their Node.js applications, enhancing the integration process.

Key Features of jsForce:

jsForce offers powerful features that allow developers to integrate Salesforce more easily. It supports easy authentication methods such as OAuth 2.0, allows for complete CRUD operations on Salesforce records, and offers extensive querying capabilities with SOQL. Furthermore, its Composite API functionality improves performance by performing several tasks in a single request.

Below are the key features of jsForce:

Simple Authentication: Support for OAuth 2.0 and basic username-password authentication methods. 

CRUD Functionality: Full CRUD operations—create, read, update, and delete—on Salesforce records. 

Advanced-Data Querying: Efficiently query and retrieve Salesforce data using SOQL.

Composite API: Execute multiple actions in a single request, improving batch processing and overall performance. 

Setting Up jsForce in Node.js: A Step-by-Step Guide

Before delving into the intricacies of CRUD operations, the initial step involves setting up jsForce in your Node.js environment. Ensure you have the required Salesforce account credentials for connecting to your specific Salesforce instance.

Step 1: To integrate jsForce into your Node.js project, initiate the installation process by running the npm command “npm install jsforce.”

npm install jsforce

Step 2: To authenticate with Salesforce using jsForce for OAuth authentication in Node.js, you’ll use the login method, which supports the OAuth 2.0 Web Server Flow. This flow involves redirecting the user to the Salesforce login page, where they log in and grant permissions. Subsequently, Salesforce redirects the user back to your application with an authorization code, which your app exchanges for an access token and refresh token.

Below is a Node.js example demonstrating OAuth authentication using jsForce:

OAuth 2.0 Flow with jsForce

Step-by-Step Guide to Get Client ID and Client Secret in Salesforce

Creating a Connected App in Salesforce is essential for obtaining the Client ID and Client Secret required for OAuth authentication. Follow this step-by-step guide to set up your app and securely access these credentials.

Step 1: First, log into your Salesforce account with an administrator or developer profile.

Step 2: In Salesforce Lightning, click on the gear icon (top right corner) → Setup → In the Quick Find box, type App Manager.

1

Step 3: In App Manager, click on the New Connected App button.

2

Step 4: Fill out the required fields for your new connected app:

3
  • Connected App Name: A name for your app, e.g., “My Node.js App”.

  • API Name: This will be auto-generated, but you can change it if needed.

  • Contact Email: Enter your email address.

OAuth Settings:

Under the API (Enable OAuth Settings) section:

  • Enable OAuth Settings: Check this box to enable OAuth for your connected app.
  • Callback URL: This is the URL Salesforce will redirect to after the user authorizes the app. For local development, it can be something like http://localhost:3000/oauth/callback. Make sure the URL matches what you use in your Node.js app.
  • Selected OAuth Scopes: Select the required OAuth scopes for your application. Common scopes include:
    • Full access (full)
    • Perform requests on your behalf at any time (refresh_token, offline_access)
    • Access and manage your data (api)

You can add multiple scopes based on your requirements, but full and api are typical for most use cases.

Click Save once you’ve completed the form.

Step 5: After creating a Connected App in Salesforce, you will be redirected to the Connected App details page, where you can access the following crucial information:

  • Consumer Key (Client ID): This unique identifier is assigned to your connected app and is utilized in the OAuth flow to differentiate your app.
  • Consumer Secret (Client Secret): This secret key is paired with the Consumer Key and is essential for authentication via OAuth. It should be handled securely to prevent unauthorized access.

Note: It’s important to remember that the Consumer Secret is only visible when you initially create the Connected App or when you view the app after creation. If you lose the Consumer Secret, you’ll need to regenerate it from the app settings.

Once the Connected App is created, it may take a few minutes, typically around 5–10 minutes, for the app to be fully accessible and active across all environments in Salesforce. During this period, you may encounter difficulties when attempting to authenticate with the app until it is fully propagated.

CRUD Operations in Salesforce Using jsForce

Learn how to perform CRUD operations in Salesforce using jsForce, including creating, reading, updating, and deleting records. Explore advanced capabilities like leveraging the Composite API for efficient bulk operations in a single API call.

Step 1: To create a new record in Salesforce, we use the create method on the sobject API. For example, let’s create a new Account record.

Here, we create an Account with the name “Acme Corporation” and the industry set to “Technology.” After the creation, the result.id will provide the unique ID of the newly created record.

Step 2: To read data, you can query Salesforce using SOQL. Here’s how to fetch records of the Account object.

This query will retrieve all Account records where the Industry is “Technology.” You can modify the SOQL query as per your requirements.

Step 3: To update an existing record, you need to know the Salesforce record’s ID. Here’s how you can update an existing Account:

In this case, the Industry field of the Account with the given ID is updated to “Finance.”

Step 4: To delete a record, use the destroy method by passing the record’s ID.

Using the Composite API for Bulk Operations

The Composite API in jsForce allows you to send multiple related requests in a single call, making it ideal for batch operations involving multiple records or dependent operations.
Here’s an example demonstrating how to use the Composite API for bulk operations in order to create a new Account and a related Contact in a single API call:

Where to Find the Correct API Version (vXX.X)

To find the available API versions in Salesforce, follow these steps:

a1

Step 1: In Salesforce Lightning, click on the gear icon located in the top-right corner of the screen. Select “Setup” from the dropdown menu.

Step 2: On the Setup page, locate the Quick Find box.

Step 3: Type “API” into the Quick Find box and select “API” from the available options.

Step 4: On the API page, you will find a section that lists different WSDL (Web Services Description Language) versions.

Step 5: Click on the respective WSDL version to open an XML document.

Step 6: In the XML document, you will find the API version specified at the top of the document.

By following these steps, you can easily locate and identify the available API versions in Salesforce through the Setup menu in Salesforce Lightning.

Breakdown of the Composite API Request:

  • allOrNone: If set to true, all operations must succeed, or none are executed. This ensures transactional integrity.
  • compositeRequest: Contains an array of individual operations. In this case, we’re creating both an Account and a Contact record.
  • referenceId: Used to reference other operations within the composite request. Here, we use @{ref1.id} to associate the Contact with the newly created Account.

Benefits of using Composite API in Salesforce

The Composite API in Salesforce offers a powerful way to streamline operations by combining multiple actions into a single request. This enhances efficiency, ensures data consistency, and simplifies complex workflows for optimized performance.

Below are the benefits of using Composite API in Salesforce:

  • Reduced API Calls: Performing multiple operations in a single request helps reduce the number of API calls required, which can result in lower overhead and improved performance.
  • Atomic Transactions: The Composite API allows you to group multiple operations as a single transaction. This ensures that either all operations succeed or all fail, maintaining data consistency across all related operations.
  • Ease of Use: The Composite API simplifies the process of managing complex, multi-step operations. By combining related requests into a single call, it streamlines the workflow and improves the overall user experience.

By leveraging the Composite API, you can achieve these benefits and optimize your application’s performance and data integrity while simplifying the handling of complex operations in Salesforce.

No Data Found.

Related Articles
How to Integrate NikoHealth to Salesforce

Healthcare organizations using NikoHealth often need patient, insurance, order, invoice, and prescription data available inside Salesforce. As data grows, manually updating records across systems becomes difficult and can lead to delays, duplicate work, and data inconsistencies. NikoHealth to Salesforce integration helps solve this challenge by automatically synchronizing data between both platforms. Instead of building custom […]

Read More
Orchestrator vs. Traditional Flows

Businesses use Salesforce automation to reduce manual work, improve efficiency, and automate repetitive business processes. Two commonly used automation approaches inside Salesforce are Traditional Flows and Flow Orchestrator. Traditional Flows are mainly used for simple automation tasks such as updating records, sending notifications, creating tasks, and automating business logic. Flow Orchestrator is designed for more […]

Read More
The Rise of Agentic Government_ What Salesforce’s 2026 Insights Mean for the Future of Public Sector AI

Government technology has often been seen as slower to evolve than the private sector. But Salesforce’s latest research challenges that idea in a big way. In fact, the new findings suggest that public sector organizations may now be moving faster than many businesses when it comes to adopting AI agents and preparing for a more […]

Read More
How To Use Email Service in APEX

Managing approvals, updates, and record changes directly from email can significantly improve efficiency within Salesforce workflows. Instead of logging in, navigating records, and manually updating fields, users can simply respond to emails and trigger automated updates using Email Service in APEX. This approach is especially useful for businesses leveraging Salesforce automation and looking to enhance […]

Read More
Design and Implementation of Salesforce Jira Task Integration 1 1

Businesses have been using Salesforce for CRM operations and Jira for Agile project tracking. However, without integration, teams manually update both systems, leading to data inconsistency and inefficiency.This mechanism establishes a real-time integration between Salesforce and Jira, allowing seamless synchronization of tasks and agile board statuses.  A custom Salesforce dashboard was developed that replicates Jira-style […]

Read More
Dark Mode in Salesforce Enabling It and Creating Theme Ready Lightning Web Components with SLDS 2.0 1 1

With the Winter ’26 release, Salesforce introduced Dark Mode in Lightning Experience. Dark Mode has been introduced as a beta feature in Winter ’26, and at first it was available only for Starter Edition orgs. It is now rolling out further with Spring ’26 to Professional, Enterprise, and Developer editions. To use Dark Mode, Salesforce […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203239658
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818