0

I'm looking to bulk update Salesforce records with NodeJS. I've been using the JSForce library for most Salesforce transactions and it works great, however the Bulk Update method only seems to Bulk update a set of records with the same information (https://jsforce.github.io/document/#bulk-query).

I'm looking to Bulk Update multiple records with different data.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
Patrick
  • 493
  • 1
  • 6
  • 10

2 Answers2

1

Follows the code of a Upsert

I hope I was helpful

require('dotenv').config();

    var jsforce = require('jsforce');
    var conn = new jsforce.Connection({
      loginUrl : 'https://test.salesforce.com'});
    conn.login(process.env.USER_NAME,process.env.PASSWORD, function(err, res) {


      var csvFileIn = require('fs').createReadStream("CSV_TEST.csv");



      var idExerno = {extIdField: 'BR_CNPJ__c'};

      conn.bulk.load("Account","upsert",idExerno,csvFileIn,function(err, rets) {
        if (err) { return console.error(err); }
        for (var i=0; i < rets.length; i++) {
          if (rets[i].success) {
            console.log("#" + (i+1) + " loaded successfully, id = " + rets[i].id);
          } else {
            console.log("#" + (i+1) + " error occurred, message = " + rets[i].errors.join(', '));
          }
        }
        // ...
      });

    });
0

I was wrong, the JSForce library does handle Bulk Updates. The API reference enumerates the operations available.

These bulk operations are allowed in the JSForce library: 'insert', 'update', 'upsert', 'delete', 'hardDelete', or 'query'

Example: conn.bulk.createJob("Account", "upsert");

Documentation: https://jsforce.github.io/document/#load-from-records

API Reference: http://jsforce.github.io/jsforce/doc/Bulk.html

Patrick
  • 493
  • 1
  • 6
  • 10