cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

Parent.Default updated onaction of barcode button

Hi

 

I'm currently learning about how to use PowerApps and I've stumbled upon a problem.

I have an EditForm with many fields that sometimes are blank and sometimes contains data.

I want to use BarCodes for the ID's, and i can get it working if it's a blank box, but i cant get it to show the old value.

 

Scenario:

This is the field and the button to activate "Set(ScannedCode1, ScanBarcode())"

image.png 

image.png

Then i have "DataCardValue17" set to "ScannedCode1", which autofills with the value from the barcode.

 

The issue I'm having, is that i want to show the "Default.Parent" value first, and IF i scan a barcode, to replace the preentered text.

I experimented with UpdateIf and UpdateContext but couldn't quite figure out how to use them for this.

 

Anyone able to help? 🙂

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
New Member

I found a workaround.

 

On the Camera image, I've added the OnSelect to

UpdateContext({LaptopScan: ScanBarcode()}); UpdateContext({LaptopScanned: true})

 

then the DataCardValue17 (the edit box for the laptop id) i reference an If to ensure that only if we have a value in LaptopScan that it will load.

If(LaptopScanned, LaptopScan, Parent.Default)

 

This presented the issue that when going to the next person to add an ID to, it would autofill the data from the previous user, overwriting the Parent.Default that might already be present.

 

To fix this, I've added on the Cancel button

ResetForm(EditForm1);Back();UpdateContext({LaptopScanned: false})

 

and on the EditForm button when first going in to edit the user details

EditForm(EditForm1);Navigate(InventoryEdit, ScreenTransition.None); UpdateContext({LaptopScanned: false})

 

This fixed my issue. I feel there should be a more elegant solution but it works! 🙂

View solution in original post

2 REPLIES 2
New Member

I also tried adding this code to the button OnSelect, but it comes up with an error:

"Set(DataCardValue17,ScanBarcode())"

 

image.png

New Member

I found a workaround.

 

On the Camera image, I've added the OnSelect to

UpdateContext({LaptopScan: ScanBarcode()}); UpdateContext({LaptopScanned: true})

 

then the DataCardValue17 (the edit box for the laptop id) i reference an If to ensure that only if we have a value in LaptopScan that it will load.

If(LaptopScanned, LaptopScan, Parent.Default)

 

This presented the issue that when going to the next person to add an ID to, it would autofill the data from the previous user, overwriting the Parent.Default that might already be present.

 

To fix this, I've added on the Cancel button

ResetForm(EditForm1);Back();UpdateContext({LaptopScanned: false})

 

and on the EditForm button when first going in to edit the user details

EditForm(EditForm1);Navigate(InventoryEdit, ScreenTransition.None); UpdateContext({LaptopScanned: false})

 

This fixed my issue. I feel there should be a more elegant solution but it works! 🙂

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (93,541)