cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
clare-sy
Frequent Visitor

update record with barcode scanner

Hi All,

 

I used barcode scanner in my app, in editform, the barcodescanner.value has been transfered to a label(lets call it "CTN" column) so that the label shows what scaner get;my code is below:

 

the label's default properity= If(IsBlank(Parent.Default),BarcodeScanner1.Value,Parent.Default)

 

which means if the label is blank(mostly in a newform ), then it shows the scanner's value;if label is not blank(maybe I  need to change some other value, I hope it stays originally, not changed);

 

 

 

but ,here is my question:

 

IF I need to update the "CTN“  in an item that already exists, I select the scanner, but the label's content stay the parent.default(even if I delete the content in label) , not my new scanner value.

 

 

 

Thank you!

 

clare

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @clare-sy ,

Do you mean that:

if CTN column is blank, the label display as blank by default;

if CTN column is not blank, the label display this item value by default;

There's a scanner button, if you click that to scan barcode, the label will display as new barcode value?

If so, you could set like this:
1)barcodescanner's OnScan:

 

Set(var,true)

 

2)CTN label's Text:

 

If(var,"aaa",Parent.Default)

 

 

Actually, no matter in edit mode or in new mode, "Parent.Default" represents this item's CTN value. If the form mode is new, "Parent.Default" value actually is blank. So no need to justify based on different form mode. You just need to justify whether you click the barcode scanner. If no, the label display based on form's mode. If yes, the label will display the scanner's scanned result.

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

4 REPLIES 4
VijayTailor
Resident Rockstar
Resident Rockstar

Hi,

You can use it like that.

If(IsBlank(Parent.Default),BarcodeScanner1.Value,If(!IsBlank(Parent.Default),Parent.Default,If( BarcodeScanner1.Value<>"Sample value" && !IsBlank(Parent.Default),BarcodeScanner1.Value)))

Thanks,
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

hi, I have tested your code, I am not sure what do you means "Sample value" , in my case , every items contains different CTN value, I change the "Sample value"  into my CTN column, here is my code:

If(
IsBlank(Parent.Default), BarcodeScanner1.Value,
If(!IsBlank(Parent.Default),Parent.Default
If(And(BarcodeScanner1.Value <> ThisItem.CTN,!IsBlank(Parent.Default)),
BarcodeScanner1.Value
)))

but if I want to update my CTN value with barcode scanner , the value turns out to be the original value;

in my view, if the parent.default is not blank , the value would be parent.default because of code: If(!IsBlank(Parent.Default),Parent.Default

clare

Hi,

You can Achieve your requirement like Below. 

Step 1. Select BarCodeScanner and Set the OnScan Properties LIke that - UpdateContext({RescanBarCode:true})

VijayTailor_0-1600942948295.png

Setp 2 - Replace the TextInput1.Text  to Parent.Default . in below Formula.
If(RescanBarCode && TextInput1.Text <> BarcodeScanner1.Value,BarcodeScanner1.Value,TextInput1.Text)

VijayTailor_1-1600943060823.png

and Test.

Please find below  the Tested Screenshot from the Android Mobile

VijayTailor_0-1600943417728.png

 


Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."


v-yutliu-msft
Community Support
Community Support

Hi @clare-sy ,

Do you mean that:

if CTN column is blank, the label display as blank by default;

if CTN column is not blank, the label display this item value by default;

There's a scanner button, if you click that to scan barcode, the label will display as new barcode value?

If so, you could set like this:
1)barcodescanner's OnScan:

 

Set(var,true)

 

2)CTN label's Text:

 

If(var,"aaa",Parent.Default)

 

 

Actually, no matter in edit mode or in new mode, "Parent.Default" represents this item's CTN value. If the form mode is new, "Parent.Default" value actually is blank. So no need to justify based on different form mode. You just need to justify whether you click the barcode scanner. If no, the label display based on form's mode. If yes, the label will display the scanner's scanned result.

 

 

Best regards,

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

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,290)