cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Chris_Fuglsang
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
Chris_Fuglsang
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
Chris_Fuglsang
New Member

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

"Set(DataCardValue17,ScanBarcode())"

 

image.png

Chris_Fuglsang
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! 🙂

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (3,733)