The barcode scanner starter kit example provides an LWC triggered from a global quick action on the landing page, for a user to scan a barcode and do a record lookup based on its value. Upon scanning the barcode of a supported type, the component does a GraphQL query on the returned value, to search the Product
records with a matching barcode value, and displays the associated record to the user.
Note that records prefetched in the briefcase can be searched while the device is offline.
-
Configure your Offline Briefcase with the
Product
sObject. -
Make the Barcode Lookup global quick action available on your landing page. You can do this either by configuring the landing page to show all global quick actions on the page, or by configuring the Barcode Lookup global quick action specifically.
See the "Global Actions" section of the Customize The Landing Page documentation, which will show you how to configure your chosen option for displaying global quick actions on your landing page. You can also consult one of the landing page templates in the project, such as
landing_page_healthcare.json
, to see how the configuration steps in the docs are implemented in the landing page templates. -
Deploy the
scanBarcodeLookup
LWC, theviewProduct2Record
LWC, theProduct2 view
quick action, thescanBarcodeLookup
quick action,landing_page.json
andlanding_page.resource-meta.xml
to your org. -
Add the global action to publisher layout.
-
After setting up the
scanBarcodeLookup
LWC, it can now be used as a Global Quick Action within the landing page. -
When you tap on the Barcode Lookup Global Quick Action in the app, you should see a screen with a Scan Barcode button.
Note Only the prefetched records in the briefcase can be searched when using this quick action while your device is offline.
-
Click the Scan Barcode button to see the camera preview.
-
Use the camera to scan an EAN-13 barcode.
-
Upon scanning the barcode, you should be presented with a view of the
Product
record associated with theProductCode
value encoded in the barcode. If no record is found for that product code / barcode, an error screen is displayed.