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

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (62,497)