How to use Barcode scanner feature in Dynamics 365 for Phones App using Javascript?

Invokes the device camera to scan the barcode information, such as a product number.

Syntax:

Xrm.Device.getBarcodeValue().then(successCallback, errorCallback);

Parameters:

Parameter Name Type Required Description
successCallback Function Yes A function to call when the barcode value is returned as a String.
errorCallback Function Yes A function to call when the operation fails. An error object with the message property (String) will be passed that describes the error details.

Return Value: On success, returns a string containing the scanned barcode value.

Note: This method is supported only for the mobile clients.

Example: Created a Scan Barcode button on Account Form and configured the below function on OnClick of the button.

function GetBarcodeValue() {
 Xrm.Device.getBarcodeValue().then(
 function success(result) {
 Xrm.Navigation.openAlertDialog({ text: "Barcode value: " + result });
 },
 function (error) {
 Xrm.Navigation.openAlertDialog({ text: error.message });
 }
 );
}

Output:

1.Open Dynamics 365 for Phones App in Mobile or Tablet,

2.Navigate to Accounts and open any Account record and Tap on commands (…).

3.Tap on Scan Barcode.

Screenshot_2017-12-28-10-19-52-172_com.microsoft.crm.crmphone

4.Mobile inbuilt Barcode Scanner app will be opened. Place a Bar Code and scan for it.

Screenshot_2017-12-28-13-13-00-570_com.microsoft.crm.crmphone

5.Once the App identifies the Barcode correctly, it will capture the Barcode Value.

Screenshot_2017-12-28-13-08-00-481_com.microsoft.crm.crmphone

Hope you learned a new thing today :):):)

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.