Barcode scanning in mobile app - Business Central
Barcode scanning in mobile app - Business Central
Goto WCMI to know more.
Adding barcode scanning to the mobile app
In this article
APPLIES TO: Business Central release wave 2 (version 23.0) and later; Business Central mobile app version 4.0 or later.
Business Central offers native barcode scanning support in the mobile app and AL language, enabling developers to provide barcode scanning capability to users of the mobile app. Barcode scanning works on supported phones and tablets, either using the device's camera or a dedicated Android barcode scanner device.
Supported scenarios
There are three different supported scenarios for adding barcode scanning to the mobile. The scenarios have varying levels of complexity. The approach you choose depends design needs, the scanner, and the device's operating system. The following table provides an overview.
Scenario Description Device camera Dedicated scanner iOS device Android device Online On-premises 1: UI button on a field The user scans a barcode by manually selecting a button next to a field 2: Invoke from AL Based on AL code, the barcode scanning capability is started when something happens, for example, a page opens, or the user selects a custom action on the page. * 3: Integrate dedicated barcode scanner Enable the use of professional hardware scanners. * ** Business Central release wave 1 (v24) and later
Supported barcodes
The barcode scanning capability supports several of the most common 1D and 2D barcode formats, including:
- QR code
- Data Matrix
- UPC A
- UPC E
- EAN 8
- EAN 13
- Code 39
- Code 93
- Code 128
- Codabar*
- ITF
- RSS14*
- RSS Expanded*
- PDF 417
- AZTEC
* Not supported on iOS devices
Control add-in APIs and .NET-based APIs
Version 24 introduced barcode scanning APIs based on control add-ins to replace the .NET-based APIs. The control add-in APIs support scenarios 2 and 3 for both Business Central online and on-premises, unlike the .NET-based APIs that are only for on-premises. You can still use the .NET-based APIs but the control add-in APIs are the recommended way to implement barcode scanning capability going forward.
Important
With the control add-in APIs, there's no associated UI on the page, meaning no embedded iFrame or visual indicator. Also no scripting or styling functionality is provided.
Requirements
- The field used for storing scanned barcodes is either text and code data type, which are the only two data types that support barcode scanning.
- Mobile device is using Business Central mobile app version 4.0 or later. To download the latest version, go to https://aka.ms/bcmobileapp.
- Dedicated barcode scanners must be running Android 11 or later.
Scenario 1: Add a barcode scanning UI button on a field
The simplest way to provide barcode scanning capability in the mobile app is by adding a barcode scanning button on a field that starts the barcode scanner capability of the device's camera.
This scanning is highly efficient and responsive. Once a barcode is scanned, its value is entered in the field on the page, and the focus moves to the next quick-entry field on the page.
To enable the barcode scanning button on a field, set the ExtendedDatatype property to Barcode
. You can set ExtendedDatatype on either the field in the table or page. The property instructs the mobile client to display the barcode button when the page is opened on a supported device.
The following code shows an example that adds a field with a barcode scanning button to the Item card page.
pageextension ItemBarcode extends "Item Card"
{
layout
{
addlast(Item)
{
field("Barcode"; Rec.GTIN)
{
Caption = 'Barcode';
ExtendedDatatype = Barcode;
}
}
}
}
Scenario 2: Invoke barcode scanning programmatically from AL
Invoke barcode scanning using control add-in API
The following code example shows how to invoke barcode scanning using the CameraBarcodeScannerProviderAddIn
control add-in.
page "Camera Barcode Scanner"
{
PageType = Card;
ApplicationArea = All;
Caption = 'Camera Barcode Scanner Sample';
layout
{
area(Content)
{
// Declare the user control based on the CameraBarcodeScannerProviderAddIn control add-in
usercontrol(BarcodeControl; CameraBarcodeScannerProviderAddIn) // Step 1
{
ApplicationArea = All;
// The ControlAddInReady event is raised when the control add-in is ready to be used.
trigger ControlAddInReady(IsSupported: Boolean)
begin
// Set the CameraBarcodeScannerAvailable variable to the value of the IsSupported parameter
CameraBarcodeScannerAvailable := IsSupported; // Step 2
end;
// The BarcodeAvailable event is raised when a barcode is available.
trigger BarcodeAvailable(Barcode: Text; Format: Text)
begin
Message(Barcode);// Step 4
// Continious scanning
// CurrPage.BarcodeControl.RequestBarcodeAsync(); // Step 5
end;
// The BarcodeFailure event is raised on a failure
trigger BarcodeFailure(Reason: Enum BarcodeFailure)
begin
case Reason of
Reason::Cancel:
Message('Canceled');
Reason::NoBarcode:
Message('No Barcode');
Reason::Error:
Message('Error');
end;
end;
}
}
}
actions
{
area(Processing)
{
action(ScanBarcode)
{
ApplicationArea = All;
trigger OnAction()
begin
// Request a barcode
CurrPage.BarcodeControl.RequestBarcodeAsync(); // Step 3
end;
}
}
}
var
CameraBarcodeScannerAvailable: Boolean;
}
Inspect the CameraBarcodeScannerProviderAddIn API in BCApps GitHub repo.
Invoke barcode scanning using .NET-based API (on-premises only)
The basic steps for implementing this scenario are:
- Define the barcode scanner provider by declaring a
DotNet
variableMicrosoft.Dynamics.Nav.Client.Capabilities.CameraBarcodeScannerProvider
. - Verify the barcode scanner provider exists in context of the client. For example, if the user is working in the Business Central web client, this step returns false.
- Create the barcode scanner. For example, this step could inside a page action.
- Call the camera action on the device.
- Depending on whether the barcode is scanned successfully, call either the
BarcodeAvailable
orBarcodeFailure
triggers.
This following code shows an example of how to start the barcode scanning when a page opens.
Tip
For a detailed implementation as used in the Business Central base application, refer to source code of the Item Tracking Lines page (ItemTrackingLines.Page.al).
page "MyALPage"
{
Caption = 'MyPage';
PageType = List;
ApplicationArea = All;
UsageCategory = Lists;
layout
{
area(content)
{
}
}
var
[RunOnClient]
[WithEvents]
CameraBarcodeScannerProvider: DotNet CameraBarcodeScannerProvider; // Step 1
trigger OnOpenPage()
begin
if not CameraBarcodeScannerProvider.IsAvailable then begin // Step 2
Message('Not available');
exit;
end;
CameraBarcodeScannerProvider := CameraBarcodeScannerProvider.Create(); // Step 3
CameraBarcodeScannerProvider.RequestBarcodeAsync(); // Step 4
end;
trigger CameraBarcodeScannerProvider::BarcodeAvailable(Barcode: Text; Format: Text) // Step 5
begin
Message(Barcode);
exit;
end;
trigger CameraBarcodeScannerProvider::BarcodeFailure(failure: DotNet "CameraBarcodeScannerProviderFailure") // Step 5
begin
if failure = failure.Cancel then
Message('Cancelled');
exit;
if failure = failure.NoBarcode then
Message('NoBarcode');
exit;
if failure = failure.Error then
Message('Error');
exit;
end;
}
Scenario 3: Integrate dedicated barcode scanners
This scenario enables the use of professional hardware barcode scanners, like Zebra or Datalogic, with the mobile app. The design is aimed at enhancing the efficiency of users, like warehouse employees, who need to scan many items in the span of a few seconds. While the user scans a series of items, the system processes the incoming barcodes.
A significant benefit of this scenario is that it allows for scanning barcodes and creating documents without the need for user interaction with the UI. When a barcode is scanned, the value is transmitted to the Business Central mobile app and then to the AL code. After AL intercepting an event from the Android device, AL code then processes the decoded barcode.
Contact us to discuss your requirements of Customizable Barcode Scanning Applications. Our experienced sales team can help you identify the options that best suit your needs.
Prepare barcode scanners
For barcode scanners to communicate with the Business Central mobile app, they must be configured to emit Android Intent messages for every scanned barcode. By default, the mobile app is programmed to listen for certain types of messages from the barcode scanners. To enable this communication, you need to adjust the scanner's settings according to the values outlined in the following table:
Scanner setting Value Intent delivery mode broadcast intent Intent action com.businesscentral.barcode.receive_barcode Intent category com.businesscentral.barcode.receive_category Intent barcode string com.businesscentral.receive_barcode.barcode_string Intent barcode type com.businesscentral.receive_barcode.barcode_formatConsult the manufacturer's guidelines for your specific scanner to learn how to modify these settings. For example, if you're using a Datalogic scanner, you can follow the instructions at Configuring the Barcode Scanners on Datalogic Terminals To Work With TSL® Mobile Apps.
Note
With some barcode scanner devices, such as Zebra, you can't modify the intent configuration. In this case, you can pass the intent data strings via AL.
Add barcode scanner functionality using control add-in API
The following code example shows how to invoke barcode scanning using the BarcodeScannerProviderAddIn
control add-in.
page "Barcode Scanner"
{
PageType = Card;
ApplicationArea = All;
Caption = 'Barcode Scanner Sample';
layout
{
area(Content)
{
// Declare the user control based on the BarcodeScannerProviderAddIn control add-in.
usercontrol(BarcodeControl; BarcodeScannerProviderAddIn) // Step 1
{
ApplicationArea = All;
// The ControlAddInReady event is raised when the control add-in is ready to be used.
trigger ControlAddInReady(IsSupported: Boolean)
begin
// If the barcode scanner is supported, request the barcode scanner.
if IsSupported then // Step 2
CurrPage.BarcodeControl.RequestBarcodeScannerAsync(); // Step 3
end;
// The BarcodeReceived event is raised when a barcode is received from the barcode scanner.
trigger BarcodeReceived(Barcode: Text; Format: Text)
begin
Message(Barcode); // Step 4
end;
}
}
}
}
Inspect the BarcodeScannerProviderAddIn API Inspect in BCApps GitHub repo.
Add barcode scanner functionality using .NET-based API (on-premises only)
In AL an extension, you add code that instructs the mobile app to listen for scanned barcodes. Barcode scanning is set up per page, which means that multiple barcode providers can be registered. However, incoming scanned barcodes are always sent to the current page open in the mobile app.
The basic steps for implementing this scenario are:
- Specify the barcode scanner provider by declaring a
DotNet
variable forMicrosoft.Dynamics.Nav.Client.Capabilities.BarcodeScannerProvider
. - Verify the barcode scanner provider exists in context of the client using the
BarcodeScannerProvider.IsAvailable
method. For example, if the user is working in the Business Central web client, this step returns false. - Create the barcode scanner using the
BarcodeScannerProvider.Create()
method. For example, this step could be called from a page action. - Instruct the app to listen for barcodes using the
BarcodeScannerProvider.RequestBarcodeScannerAsync()
method.
page "BarcodeScannerReceiver"
{
Caption = 'BarcodeScannerReceiver';
PageType = List;
ApplicationArea = All;
layout
{
area(content)
{
group(General)
{
Caption = 'General';
}
}
}
var
[RunOnClient]
[WithEvents]
BarcodeScannerProvider: DotNet BarcodeScannerProvider; //Step 1
trigger OnOpenPage()
begin
if not BarcodeScannerProvider.IsAvailable then begin // Step 2
Message('BarcodeScannerProvider Not Available');
exit;
end;
BarcodeScannerProvider := BarcodeScannerProvider.Create(); // Step 3
BarcodeScannerProvider.RequestBarcodeScannerAsync(); // Step 4
end;
trigger BarcodeScannerProvider::BarcodeReceived(Barcode: Text; Format: Text) // Result
begin
Message(Barcode);
exit;
end;
}
Top 6 Applications for Barcodes in Warehouse and ...
Enhance Operational Efficiency and Reduce Errors with Barcode Scanners
The barcode scanner has become an indispensable tool in warehouse and manufacturing environments, revolutionizing the way businesses manage and track their inventory. The use of the barcode reader offers numerous benefits, including increased accuracy, efficiency, and reduced human errors. Any manual data collection system will never rival the speed and reliability of automated data collection through a barcode scan.
While many companies make use of barcode labels, they may not take full advantage of the technology for all the workflows where it can be helpful. Also, some companies still rely on manual data collection (pen and paper) for key business processes. Wed like to explore the top six applications for barcodes in manufacturing and warehouse applications, and also discuss some of the hardware necessary to create an effective barcode scanning solution. CSSI Technologies is an expert in barcode scanning and mobile computing technologies as well as barcode software. We can help you further explore and implement any of these workflows.
1. Inventory Management
Barcodes play a pivotal role in streamlining inventory management processes. Inventory items are assigned a barcode, allowing for quick and accurate tracking of stock levels. Barcode scanners can effortlessly scan items during receiving, picking, and shipping, providing real-time updates on the accurate inventory level. This not only minimizes errors but also ensures that the right products are in the right place at the right time. Improved inventory control has multiple benefits: more efficient labor operations, less lost inventory, and more inventory tracking accuracy which results in higher sales and the ability to turn inventory faster.
Hardware Required: Barcode scanners, mobile computers, warehouse management software (WMS), and label printers.
2. Order Picking
Order picking is a critical aspect of warehouse operations. Barcodes enable a more efficient and error-free picking process. Warehouse staff equipped with a mobile device can scan barcodes on items and bins to verify product information and confirm that the correct items are being picked for an order. This reduces the likelihood of mistakes and speeds up the fulfillment process. The company benefits by accelerating the speed of picking and reducing errors (mis-picks) which can lead to expensive returns and lower customer satisfaction.
Hardware Required: Handheld barcode scanners, wearable scanners, mobile computing devices, and warehouse management software (WMS).
3. Shipping and Receiving
Barcodes simplify the shipping and receiving process by providing accurate data capture. When products arrive at a warehouse, their barcodes are scanned to update the inventory system automatically. Similarly, during the shipping process, barcodes are scanned to confirm that the correct items are being sent to the right destination. This minimizes shipping errors and improves overall order accuracy. Barcodes allow the company to ensure that the correct products are received and routed to the correct destinations, and can accelerate the invoicing process.
Hardware Required: Barcode scanners, mobile computers, shipping software, and thermal label printers.
4. Quality Control
Maintaining product quality is crucial in manufacturing. Barcodes are used to track and trace raw materials and finished goods throughout the production process. Quality control checkpoints can be established where barcode labels are scanned to ensure that products meet specified standards. A scanned barcode allows you to electronically link QC actions to an electronic record, providing proof of what checks were made. See CSSIs case study of custom quality control software created for an industrial customer to track lab samples.
Hardware Required: Barcode scanners, mobile computers, and quality control software.
5. Work-in-Process Tracking
In a manufacturing environment, barcodes facilitate real-time tracking of work-in-progress (WIP). Each stage of the production process can be assigned a unique barcode, allowing for accurate monitoring of the production flow. This visibility aids in identifying bottlenecks, improving efficiency, and meeting production deadlines. Barcode technology can reduce missed manufacturing steps and provide company management with visibility and metrics on the state of production at any point in time.
Hardware Required: Barcode scanners, mobile computers, and manufacturing execution systems (MES).
6. Asset Tracking
Barcodes extend beyond product tracking and are invaluable for monitoring equipment and assets within a warehouse or manufacturing facility. Each asset can be assigned a barcode, enabling easy identification and tracking of its location and maintenance history. This helps in optimizing asset utilization and reducing downtime. The company can reduce losses from stolen or misplaced assets and can create accountability for check-in/check-out procedures.
Hardware Required: Barcode scanners, mobile devices, and asset tracking software.
How to Get Started Implementing Barcode Technology
Of course, there are many more possibilities beyond the top 6 applications for barcodes in manufacturing and warehousing. The adoption of barcodes in industrial, distribution center, and transportation/logistics environments has transformed traditional inventory and operational processes. The efficiency, accuracy, and real-time visibility provided by barcodes contribute significantly to overall productivity. To implement a successful barcode scanning solution, businesses must invest in the appropriate hardware, including barcode scanners, mobile computers, printers, and software tailored to their specific needs.
However, its also necessary to understand best-in-class workflows and how these technologies have been successfully implemented at industry peers. This is where CSSI Technologies can be of great help to you. We offer years of experience in implementing and supporting barcode technology and mobile computer implementations, as well as inventory software and barcode scanning software. By bringing our experience to the table, we can help a company get started faster, with a better outcome. Avoid unnecessary pitfalls and contact CSSI to discuss your barcode project.
For more information, please visit 1d and 2d Barcode Scanners Supplier.
Comments