cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sel_wee01
Frequent Visitor

UpdateIf Problem

Hi guys, I am new to Power Apps, sorry if this question has been answered before.

 

I'm building an app that allows users to scan products' barcode. In my app, the users can view the gallery and the display form is linked to those gallery. Once the barcode is scanned, the value will be displayed in the panel. The users then can choose whether to click 'return' or 'collect' button. Based on that, the quantity of the items will be either deducted or added.

 

Please take a look at the code:

UpdateIf(Barcode_test1,BarcodeScanner2.Value =Gallery2.Selected.Barcode, {Availability:Gallery2.Selected.Availability+1})   

 

Problem: Why the code above modify all the 'Availability' column instead of the selected one? Please help.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
gabibalaban
Super User II
Super User II

@sel_wee01 ,

You get this results because you not involved columns value of your collection Barcode_test1 in your condition. You can look at BarcodeScanner2.Value and Gallery2.Selected.Barcode as two values unrelated to Barcode_test1 collection columns and when this two values are equal  all records from Barcode_test1 are updated with {Availability:Gallery2.Selected.Availability+1}.

Use instead:

Patch(Barcode_test1,

          LookUp(Barcode_test1,BarcodeColumn=BarcodeScanner2.Value),  

         {Availability:Gallery2.Selected.Availability+1}

       )

 

Hope it helps !

View solution in original post

4 REPLIES 4
WarrenBelz
Super User III
Super User III

Hi @sel_wee01 ,

This line

BarcodeScanner2.Value=Gallery2.Selected.Barcode

is comparing (I assume) the value in the barcode to one selected in the gallery - you need to refer to the list - assuming the field is Barcode, it would be

Patch(
   Barcode_test1,
   {Barcode:BarcodeScanner2.Value}, 
   {Availability:Availability+1}
) 

 Also if you are only updating one record, use Patch.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

gabibalaban
Super User II
Super User II

@sel_wee01 ,

You get this results because you not involved columns value of your collection Barcode_test1 in your condition. You can look at BarcodeScanner2.Value and Gallery2.Selected.Barcode as two values unrelated to Barcode_test1 collection columns and when this two values are equal  all records from Barcode_test1 are updated with {Availability:Gallery2.Selected.Availability+1}.

Use instead:

Patch(Barcode_test1,

          LookUp(Barcode_test1,BarcodeColumn=BarcodeScanner2.Value),  

         {Availability:Gallery2.Selected.Availability+1}

       )

 

Hope it helps !

View solution in original post

sel_wee01
Frequent Visitor

Thank you guys! Both of the solutions work perfectly. Now I understand why it is not working with the initial code.

No problems @sel_wee01 ,

You have the option of accepting both if you desire.

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 (74,239)