Self Hosted Minimal Salesforce Workbench

Published on
1122 words
6 mins read
--- views
Authors

If you want to integrate salesforce with your app, In the begginning, you’ve heared lot of terms like SOQL, REST, etc with salesfoce. If thats confusing same as me, this article is only for you.

What is salesforce CRM?

CRM stands for Customer Releationship Management. It is a software that is used to store customer information like name, address, phone, email, etc. And also keep track of the customer activities. There are numerous CRM softwares are available out there. Salesforce CRM is the one among them and it is mostly used CRM around the world. Salesfoce CRM helps your business in terms of marketing, sales, commerce, service and IT team works which makes your customers happy.

What is Salesforce Workbench?

Salesforce workbench is a free, open source, web based application to manage the salesforce data. This allows developers and admins to integrate the salesforce with any third party application. Force.com APIs transfer data between your Salesforce environments and Workbench.

Benefits of Using Salesforce Workbench

  • Minimal, pretty fast and really easy to use.
  • Can perform both SOQL as well as REST.
  • Work with any standard or custom objects.
  • Can make use of Advanced REST Mode.
  • You can host this in your server (Self Hosted).

Apex, SOQL, Objects, Records, Visualforce other common Salesforce terms

Apex

Apex is one of the programming language developed by salesforce specifically for the Salesforce CRM. It is primarily used for writing server side code, such as triggers, classes, and controllers, to extend the capabilities of Salesforce.

Some of the key characteristics of Apex:

  • Object-Oriented : It follows OOP concept that allows developers to define and create classes, objects, and interfaces.

  • Strongly-Typed : Variables must be declared with a specific data type and cannot be implicitly converted to other types.

  • Triggers : Code snippets that execute before or after specific events like lead creation, updating or even deletion. It allows developers to perform anything based on the events and their business logic.

  • Web Services : Supports to expose custom web services, allowing external systems to interact with Salesforce and perform CRUD operations.

  • Unit Testing : It has built-in support for unit testing which allows developers to write a test cases to check the quality of the code and identifying and fixing issues early.

Visualforce

It is a web development framework developed by salesforce specifically for building custom user interfaces and pages within the Salesforce. It is a markup language that allows developers to create customized layouts, forms, and components to enhance the user experience and extend the functionality of Salesforce applications.

SOQL

SOQL (Salesforce Object Query Language) is a query language used to retrieve data from Salesforce databases. It is designed by Salesforce for quering the salesforce objects and their fields to fetch specific records that match certain criteria. Is is similar to standard SQL but with some changes that allows to work with salesforce objects.

Since it is based on standard SQL, it allows various querying techniques like get only required fields, filtering, sorting, aggregation and traversing relationships between objects.

Objects

Objects represent a table that stores specific types of data. Simply Objects are entities that holds records with related information.

It supports both standard objects and custom objects:

  • Standard Objects : These are Salesforce built-in Objects such as Account, Contact, Opportunity, Lead and etc.

  • Custom Objects : These are objects that you can create to store organization-specific data that is unique to your business processes. Custom objects allow you to define the fields, relationships, and behaviors that best suit your requirements.

Records vs Fields

Records are instance of Objects that contains specific data. whereas Fields are attributes or columns of the records such as name, phone, email, etc.

Similar to objects we can have standard salesforce fields along with organization specific custom fields.

Generate Private Key and Self-Signed Digital Certificate

This process produces two files:

  • server.key - The private key. Which is used to sign the JWT claim generated by your code.
  • server.crt - The digital certificate. You upload this file when you create the required connected app.
  1. Open a terminal or command prompt.
  2. Install OpenSSL on your computer. Please check whether it is installed or not.
  • In macOS or Linux
which openssl
  • In Windows
where openssl
  1. Change to our app directory.
cd app
  1. Generate a private key and self-signed digital certificate.
openssl req -x509 -sha256 -nodes -days 36500 -newkey rsa:2048 -keyout private-key.pem -out cert.pem

Salesforce Configuration

You can sign up for a free salesforce developer account here.

You'll get a email from salesforce on sucessfull signup. In this email, you’ll get your verification link, developer URL and user name. On verifiying, you’ll be asked to enter the password initially. Verify your password and proced which then it’ll redirect to your home page. (These are one time setup).

Once You are created your account, Follow the steps carefully,

You're required to create a connected app when using the OAuth 2.0 JWT bearer authorization flow.

  • Navigate to App Manager in Apps and Create a new connected app by clicking New Connected App in top right corner (Refer Screenshot Below).
App Manager

  • Fill basic informations like app name, API name(salesforce generate for you based on app name or else you can have your own), email, Most importantly enable OAUTH settings and give http://localhost:8080/auth/callback as callback URL , enable use digital signature and upload your digital signature that we have generated by using openssl. Select and add the required scope. (For testig you can select all the scopes). (Refer Screenshot Below)

Create Connected App

Click save and wait few minutes for salesforce to create a app for you.

Once created, click on manage consumer details, make a note of Consumer Key and Consumer Secret and fill these details in you .env file.



Running Code Locally

  • Clone the project
  git clone https://github.com/gokulselvan-r/salesforce-workbench
  • Go to the project directory
  cd salesforce-workbench
  • Install dependencies
  npm install
  • Start the server
  npm run build-n-start

Output

If you open http://localhost:8080 after running the code sucessfully, It'll look like below.

Login

Saleforce Login

SOQL

SOQL

REST


Conclusion

This minimal Salesforce workbench provides various capabilities for developers working with the Salesforce platform. It allows the developers to test and troubleshoot their integrations with the Salesforce. It provides an environment for executing REST and SOQL requests, examining response data, and debugging any issues that may arise when executing REST and SOQL requests.