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 Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,999)