While using Salesforce, your management system can conveniently extend new functionalities by installing apps from Salesforce AppExchange — the Salesforce store. How can you build a Salesforce app by yourself? In this article, I will share how to create a barcode reader app for Salesforce from scratch.
Requirement
Dynamsoft JavaScript Barcode SDK
Setting Up Salesforce Environment
Before getting started to code, there are a few configuration steps required for your Salesforce account.
The first step is no doubt to create a Salesforce account. After that, you must join the partner community if you want to publish your apps to Salesforce AppExchange.
As you sign in Salesforce, you will see two different UIs, a classic UI and a lightning UI. It is easy to switch them whenever you want.
The next step is to connect an org of developer edition in Environment Hub, for you need to build apps with a developer account.
Getting the security token in My Settings is also an important step because it will be used when you want to connect different organizations in the Salesforce partner community.
Dev Tool Installation
To build Salesforce apps, developers can install Salesforce CLI and Visual Studio Code extensions.
CLI
Install the Salesforce Command Line Interface (CLI): https://developer.salesforce.com/tools/sfdxcli
Visual Studio Code Extension
Search for “ salesforce pack “ in Visual Studio Code and install relevant extensions.
Building a Salesforce App
In Visual Studio Code, press Ctrl+Shift+P and type in “ sfdx: create project” to create a new project named BarcodeReader:
Find the project-scratch-def.json file and change the orgName according to your Salesforce account:
{"orgName": "Dynamsoft","edition": "Developer","features": [],"settings": {"lightningExperienceSettings": {"enableS1DesktopEnabled": true},"securitySettings": {"passwordPolicies": {"enableSetPasswordInApi": true}},"mobileSettings": {"enableS1EncryptedStoragePref2": false}}}
To deploy the local project to an org, you have to authorize the org beforehand.
Once the authorization is done, you can see the deployment option is available in the context menu by right-clicking.
Visualforce Page
Let’s try to create a Visualforce page called DecodeFile via SFDX command.
Afterward, the page file can be deployed to Salesforce and viewed online.
If you have successfully listed the Visualforce page, it is time to add the barcode decoding logic.
Note: To make the JavaScript barcode SDK work, you have to apply for a valid license from Dynamsoft online portal.
Save the changes and re-deploy the code. Here is the preview of the Visualforce page.
It seems good so far. Likewise, you can create another Visualforce page for decoding barcodes from a camera video stream and deploy it to Salesforce.
Custom Tabs
Hopefully, you have implemented the two Visualforce pages without trouble. To use them within the Salesforce window, you can create corresponding custom Visualforce tabs.
Making an App
Since the custom tabs are ready, you can group them into an app that works as a unit to provide functionality.
Creating a Package
Finally, you need to create a package with the app in order to publicly share the barcode decoding functionality to AppExchange.
Publishing Apps to Salesforce AppExchange
Now you can visit the Salesforce partner page to view the package. As long as you finish the business plan and pass the security review, you can submit your selected package to Salesforce AppExchange.
Source Code
Originally published at https://www.dynamsoft.com on September 18, 2020.