How to Search Dynamics 365 CRM data using Scanned Barcode value in Canvas App

By | July 29, 2020

Introduction

In our previous blog we have explained how to add Barcode Scanner in Power Apps and now we will explore how to search Dynamics 365 CRM data using the scanned barcode value. For example, in a convenience store all the products have barcodes. Once you scan these barcodes you will get the product details like name, price, size, description, etc.

In this blog, we will see how to search entity data from Dynamics 365 CRM using the scanned barcode value in Canvas App. For example, there is product entity in CRM and this product entity data will be shown when user scans the barcode of a particular product.

To achieve this, follow the steps given below:

1. Create a Canvas app and add one Home Screen to it.

2. On that Home Screen add Barcode Scanner from media as shown in below screenshot:

Barcode Scanned value in Canvas App

3. After adding Barcode Scanner control to your Home Screen, it will be displayed as follows:

Barcode Scanned value in Canvas App

4. Now in the ‘OnScan’ property of Barcode Scanner control you need to add following code.

Launch(BarcodeScanner.Value);Navigate(DetailScreen, ScreenTransition.Fade, { scanvalue: BarcodeScanner.Value } )

Note:

Launch() function is used to launch Barcode Scanner to scan the barcode from product.

Navigate() function is used to redirect to Details Screen to view data as per the scanned value.

Refer below screenshot:

Barcode Scanned value in Canvas App

5. Next, add the data source of product entity which will bind with DetailScreen (Edit Form) as shown in below screenshot:

Barcode Scanned value in Canvas App

6. Now you need to add DetailScreen to view searched record details like name, id, description, price, etc. from CRM Product.

Barcode Scanned value in Canvas App

7. Next, bind Product data source to DetailsScreen (Edit Form) as shown below:

Barcode Scanned value in Canvas App

8. In the ‘Item’ property of Edit Form you need to add the following code to filter the data using barcode value which is scanned from Barcode Scanner control:

Barcode Scanned value in Canvas App

For example, I have a product ArmBand 150 with product id – 1234567890 which is our scanned value. We will now search/filter this record using our app. Barcode scanner value is nothing but the product id field in Dynamics 365 CRM.

You can see below screen shot of Product in CRM. This data will be now populated in Canvas App.

Barcode Scanned value in Canvas App

Once we scan in app, the corresponding product data will be populated in DetailScreen with all the details as shown below:

Barcode Scanned value in Canvas App

Conclusion

In this way, we can easily search/filter Dynamics 365 CRM records in Canvas App based on Scanned Barcode Value.