cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
RobMonkman
Level: Powered On

Validate if a Barcode Scan value exists in my database or not

Hi all,

 

I'm having trouble working out the correct syntax in PowerApps for what is effectively just a simple If condition.

 

Scenario:

In D365 CE, all Contacts will have a 'CustomerID' (text field). For example, Bob Smith may have a CustomerID of "SMITH123". This will always be a unique value and I guess I could use GUID, though I may need it to be a user friendly/memorable value.

If Bob Smith then turns up to an event and we scan his ID Badge, the barcode scan result will return 'SMITH123'.

 

All I want to do is check that 'SMITH123' is a valid scan, so write a True/False value to a new field called 'ValidScan'.

 

So,

 

I have a Canvas App with a barcode scan button and the results of the scan (barcodescanner1.value) gets stored in a variable called ScanResult.

At this stage I'm also putting the barcodescanner1.value in a field on the form so I can visually see the result front end.

I also have another field where I'm pulling in the CustomerID value using the CDS connection.

I will then have a field called 'Valid Scan' which will show True/False. (I'll use an input field for this so I can do something with the True/False value).

 

All I want to do is check to see if the scan result is an exact match with the value held in my CustomerID field.

 

So the logic is simple as I've set out below, but I can't quite crack this using the PowerApps functions.

 

If

BarcodeScanner1.value = CustomerID.value

Then

Set ValidScan = True

else

ValidScan = False

end

 

Many thanks,

Rob

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Validate if a Barcode Scan value exists in my database or not

Hi @RobMonkman ,

Do you want to pupulate the 'Valid Scan' field with true/false value based on the Barcode scanned result?

 

I have made a test on my side, please consider take a try with the following workaround:

Set the Defualt property of the 'Valid Scan' field in your Edit form to following:

If(
    BarcodeScanner1.Value in 'YourCDSEntity'.CustomerID,
    "True",
    "False"
)

or

If(
    BarcodeScanner1.Value = CustomerIDTextInputBox.Text,  /* <-- CustomerIDTextInputBox represents the Text box in your Edit form to display the CustomerID value from your data source */
    "True",
    "False"
)

 

In addition, if you want to display a Boolean value within the 'ValidScan' field, please modify above formula as below:

If(
    BarcodeScanner1.Value in 'YourCDSEntity'.CustomerID,
    true,
    false
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Community Support Team
Community Support Team

Re: Validate if a Barcode Scan value exists in my database or not

Hi @RobMonkman ,

Do you want to pupulate the 'Valid Scan' field with true/false value based on the Barcode scanned result?

 

I have made a test on my side, please consider take a try with the following workaround:

Set the Defualt property of the 'Valid Scan' field in your Edit form to following:

If(
    BarcodeScanner1.Value in 'YourCDSEntity'.CustomerID,
    "True",
    "False"
)

or

If(
    BarcodeScanner1.Value = CustomerIDTextInputBox.Text,  /* <-- CustomerIDTextInputBox represents the Text box in your Edit form to display the CustomerID value from your data source */
    "True",
    "False"
)

 

In addition, if you want to display a Boolean value within the 'ValidScan' field, please modify above formula as below:

If(
    BarcodeScanner1.Value in 'YourCDSEntity'.CustomerID,
    true,
    false
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,621)