Introduction
At times there are business needs for mobile apps to scan QR codes and store the results in Salesforce. Couple of common scenarios where this is useful is:
- Scan the QR code and create a Lead or Contact in Salesforce. This is useful when registering users to events.
- Scan information about a product and update the inventory information.
Mobile Application to perform QR Code scanning
- The app scans a QR code and returns data of QR code using a plugin.
- Jsforce api creates records of specified objects on Salesforce using data returned by the QR code scanner.
Client Requirements:
The clients requirement was to create a record in Salesforce by scanning QR code using a mobile application. QR code consists of data which is required to create records in salesforce. Salesforce object can be Contact or Leads or any custom objects.
Summary
- Login using salesforce credentials to your app.
- Scan this QR code which contains information as shown in a screenshot below.
- Scan this QR code using a mobile application.
- App will create a new record in Salesforce with the value returned by QR code scanner
Technical Approach:
In QR code Scanner App we use connected app and Jsforce plugin
- Connected App
A connected app is an application that connect to Salesforce.com over identity and data API’s. Connected Apps use the standard OAuth 2.0 protocol to authenticate, provide Single Sign-On, and acquire access tokens for use with Salesforce APIs.
Connected App Name - QR Code Scanner - Jsforce plugin
JSforce (f.k.a. Node-Salesforce) is a isomorphic JavaScript Library utilizing Salesforce's API: It works both in browser and with Node.js.It capsulates the access to various APIs provided by Salesforce in asynchronous JavaScript function calls.Unlike other Salesforce API libraries, it is intended to give integrated interface both server-side and client-side apps, so you don't have to rewrite similar logics with different libraries only for running in different environment.- Backbone.js
- Forcetk.mobilesdk.js
- Forcetk.ui.js
- Underscore.js
- An overview of these libraries is given bellow:
- Forcetk.mobile.sdk is responsible for responding to connected apps.
- Forcetk.ui.js is responsible to show salesforce login ui with all login constraints
- Backbone.js and Underscore.js consist of some definition of functions which are used in jsforce library.
Conclusion:
The app was able to create the records in Salesforce from a mobile app using the QR code scanner.
For any query on QR Code Scanner, contact support@astreait.com