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.
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.
- 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
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
- 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.
The app was able to create the records in Salesforce from a mobile app using the QR code scanner.