Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jsforce/jsforce-node

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsforce/jsforce-node

Salesforce API Library for JavaScript

  • 3.5.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @jsforce/jsforce-node?

@jsforce/jsforce-node is a powerful and flexible library for interacting with Salesforce from Node.js applications. It provides a wide range of functionalities including authentication, CRUD operations, SOQL queries, and more.

What are @jsforce/jsforce-node's main functionalities?

Authentication

This code demonstrates how to authenticate with Salesforce using a username and password. The `login` method is used to establish a connection.

const jsforce = require('@jsforce/jsforce-node');
const conn = new jsforce.Connection();
conn.login('username@example.com', 'password+securityToken', function(err, userInfo) {
  if (err) { return console.error(err); }
  console.log('User ID: ' + userInfo.id);
  console.log('Org ID: ' + userInfo.organizationId);
});

CRUD Operations

This code demonstrates how to create a new record in Salesforce. The `sobject` method is used to specify the Salesforce object, and the `create` method is used to create a new record.

const jsforce = require('@jsforce/jsforce-node');
const conn = new jsforce.Connection();
conn.login('username@example.com', 'password+securityToken', function(err, userInfo) {
  if (err) { return console.error(err); }
  conn.sobject('Account').create({ Name: 'New Account' }, function(err, ret) {
    if (err || !ret.success) { return console.error(err, ret); }
    console.log('Created record id : ' + ret.id);
  });
});

SOQL Queries

This code demonstrates how to execute a SOQL query to retrieve data from Salesforce. The `query` method is used to run the SOQL query and fetch the results.

const jsforce = require('@jsforce/jsforce-node');
const conn = new jsforce.Connection();
conn.login('username@example.com', 'password+securityToken', function(err, userInfo) {
  if (err) { return console.error(err); }
  conn.query('SELECT Id, Name FROM Account', function(err, result) {
    if (err) { return console.error(err); }
    console.log('Total : ' + result.totalSize);
    console.log('Fetched : ' + result.records.length);
  });
});

Bulk Operations

This code demonstrates how to perform bulk operations in Salesforce. The `bulk.load` method is used to insert multiple records in a single API call.

const jsforce = require('@jsforce/jsforce-node');
const conn = new jsforce.Connection();
conn.login('username@example.com', 'password+securityToken', function(err, userInfo) {
  if (err) { return console.error(err); }
  const records = [{ Name: 'Account 1' }, { Name: 'Account 2' }];
  conn.bulk.load('Account', 'insert', records, function(err, rets) {
    if (err) { return console.error(err); }
    for (let i=0; i < rets.length; i++) {
      if (rets[i].success) {
        console.log('Created record id : ' + rets[i].id);
      } else {
        console.log('Failed to create record ' + rets[i].errors.join(', '));
      }
    }
  });
});

Other packages similar to @jsforce/jsforce-node

Keywords

FAQs

Package last updated on 02 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc