Write a Heroku Scheduler batch for MangoDB+Salesforce with Node.js

In previous post,I had shared how to 《Access Salesforce data via APIs(JSForce) from Outside Service》.
In this post I will share about how to write a Heroku Scheduler batch for synchronizing MangoDB data to Salesforce with Node.js, like the below outline picture.
MangoDB+Salesforce ※I have no doubt that there have many ways to do connect between MangoDB and Salesforce, such as 《 Lightning Connect Custom Adapters and MongoDB》By Enrico Murru and 《 Powering Salesforce Lightning Connect with MongoDB》, and I will try and share that in next posts separately.
Here we go.

1. In Salesforce

The Data Model

New a custom object named “MangodbObject” for storing MangoDB data. MangodbObject

2. In Cloud9 IDE

Update package.json

Add async, moment and mongoose to package.json file.

Create batch files

Create “db.js” and “sfdc.js” in root directory with the blow source code.

Depoly to Heroku

Depoly changed files to Heroku as the previous post,《Awesome Node.js development environment with Heroku and Cloud9

3. In Heroku

Add Add-ons

Add MangoLab and Heroku Scheduler to Heroku. Add-ons

Prepare test data of MongoDB

Create a collection named “accounts” and add the following data in MongoLab.

Add new job in Heroku Scheduler

Heroku Scheduler

4. Results

Heroku logs

Check Heroku logs with Heroku command “heroku logs”.

Data in Salesforce

MangoDBObject   Salesforce Now we have a batch which synchronizes data everyday from MangoLab to Salesforce. ;)
Enjoy it.

Related Post

Pipeline for Salesforce – Be less busy, less... Overview Pipeline is a metadata deploy app for Salesforce, supports: ・Quickly making Changeset from Excel/CSV, in 10 seconds or less! (Coming soon) ・No dependencies on Salesforce Org, deploying metadata between different organizations. ・Deploying metadata base on git flow, pull from Github/B...
Salesforce Smart Importer – 1-Drag to import... This is my third Chrome Extension named Salesforce Smart Importer (Other two popular extensions are Salesforce Mass Editor and Salesforce DevTools), it is designed for Salesforce not only admin but also normal user, supports : ・1-Drag to import any Excel / CSV data on anywhere in Salesforce, both ...
Salesforce Mass Editor (Chrome Extension) – ... This's my second Chrome Extension (First one is HERE) this year, named "Salesforce Mass Editor" and it supports for doing the below things : ・Makes any Salesforce list view to be a powerful mass editor. ・Mass insert, mass clone, mass update, mass delete, ALL-IN-ONE. Support for both Classic and ...
Build LINE Bot web application with Node.js and He... Overview In order to check the operation of the LINE Bot web application that using the LINE Messaging API, you need a server that can be accessed externally.This post shares the creation procedure of LineBot web application using Heroku. Basic flow 1. Heroku development environment For web onli...

Post Tagged with , , , ,