cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Patch Collection Value by Individual slider value within gallery

Hi Power-Apps community,

 

I have another challenge I am not able to solve by myself and therefore kindly ask for your help.

 

Overall use case:

I am using the OOTB-Inventory App to track my inventory stocks. All of the displayed values in the App come from a SP List called 'Inventory List'.

I now want to improve the inventory App by a separate mobile App called QR-Code Scanner. Its goal is to easily update withdrawals or restockings of items.

 

Specific use case for the QR-Code Scanner:

 

Within my warehouse each product has a unique product code that is stored in a QR code. My users are to update the inventory list immediately whenever they are restocking or withdrawing items from the warehouse. To do that I have created a mobile App that uses the barcode-Scanner control to scan a QR codes. The QR code contains the unique product ID. By scanning the QR code this product ID is extracted and stored in a collection called Coll_multiscan. This collection, Coll_multiscan, is run against another collection called Coll_Products. Coll-Products is the Collection containing all of the data of the SP List 'Inventory List', to check for the ID and look up all the column details (e.g. name, current quantity) from the SP list. 

The scanned items are then displayed in a gallery, that does not only show the Product ID but also the name and the current quantity to add user friendliness. And now I run into the catch:

My goal is to make the App as user friendly as possible. The user is supposed to work with on hand only, no typing necessary. So this is why I want to introduce the slider. 

I have added sliders to the gallery items. There the user can either slide to the right to add the amount of items he has added or slide to the left to reduce the stock. I then want to patch these individual selections to the collection Coll_Products to update the quantities. 

To do that I use the following formula:

 

 

 

 

 

ForAll(RenameColumns(Filter(ProductCollect,ID in Coll_Multiscan.Barcode_Info),"ID","EID"),Patch(ProductCollect,LookUp( ProductCollect  ,ID=EID),{'Curent Quantity':Slider5.Value}))

 

 

 

 

 

What happens then though is that not the individual slider values get passed but only the lastly selected slider value gets patched to all selected items. So if I have 2 items in the gallery and the individual selected values are

1. +4

2. -3,

 

-3 will be patched as all three quantities.

 

 Patch Problem.png

 

Anyone being able to help me?

 

Thank you and best regards

JHL 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @JHL :

Please try this code:

ForAll(
RenameColumns(GalleryName.AllItems,"ID","EID"), /*Traverse all items in the gallery (including silverer5)*/
Patch(ProductCollect,LookUp( ProductCollect,ID=EID),{'Curent Quantity':'Curent Quantity'+Slider5.Value})
)

Best Regards,

Bof

View solution in original post

6 REPLIES 6
Community Support
Community Support

Hi @JHL :

Could you tell me :

  • Are the Slider controls in a gallery?
  • What is the gallery's Items property?
  • What is the relationship between the item in the gallery and the record to be updated?

Firstly,let me explain why you encounted this problem.

It is not feasible to directly reference the value of the controls in gallery. The correct way is to traverse the table Gallery.AllItems.For example:

 

UpdateIf(
  ProductCollect,
  ID in Coll_Multiscan.Barcode_Info,
  {
   'Curent Quantity':LookUp(GalleryName.AllItems,Field1=field2).Slider5.Value
  }
)

 

I assume:

  • The name of the Gallery is "GalleryName"
  • The items in the Gallery and the records in ProductCollect are mapped through "field1" and "field2"

If you have any problems,please feel free to let me know.

Best Regards,

Bof

 

 

Hi @ 

 

  • Are the Slider controls in a gallery?
    • Yes they are supposed to be in the gallery.
    • This is important, as I want the user to the experiece that he scans the code, sees the item appear in the gallery and then instinctively reduces or increases the amount by the slider. The sliders are supposed to go along with the added items.
  • What is the gallery's Items property?
    • right now the gallery Items property is:
      Items= Filter(ProductCollect,ID in Coll_Multiscan.Barcode_Info)
    • The purpose is that I want to lookup my QR-Code 
  • What is the relationship between the item in the gallery and the record to be updated?
    • The relationship is that in the gallery items from my ProductCollect-Collection are displayed that are matching the Mulitscan.Barcode_Info. By selecting the slider I want the value of the slider be patched to the field 'Current Quantity' to replace the value within the collection. 

Now I run into the following questions:

  • I am assuming that the formula you shared with is the OnSelect-property of my Submit-Button?
  • I am assuming that the fields 1 and 2 you are referring to are 'Current Quantity'?
  • Is it overall possible achieving what I am looking for by having the sliders be part of the gallery?

 

Once again thank you bunches for your help in advance.

BR

JHL

 

 

Hi @JHL :

I get it.

Firstly,let answer your questions.

  • Q1:Yes.I'm taking about the OnSelect-property of your Submit-Button.
  • Q2:We can now skip this question, because I was not sure about your gallery settings before.
  • Q3:Yes.

Secondly,here is my solution:

1\Add a salder control into this gallery

2\Set the submit-button's OnSelect property to

 

ForAll(
 RenameColumns(GalleryName.AllItems,"ID","EID"), /*Traverse all items in the gallery (including silverer5)*/
 Patch(ProductCollect,LookUp( ProductCollect,ID=EID),{'Curent Quantity':Slider5.Value})
)

 

In addition,there is a simpler solution.

Set the silder control's OnChange property to

 

Patch(ProductCollect,ThisItem,{'Curent Quantity':Slider5.Value})

 

In this way, you don't even need to submit changes. Once the value of silder is changed, the change will be automatically submited.

Best Regards,

Bof

You @v-bofeng-msft  are the man. Thank you so much for your help on this one.

One last question:

If I wanted to substract the slider value from the 'Current Quantiy' how would you do this?

 

Thank you and best regards

JHL 

Hi @JHL :

Please try this code:

ForAll(
RenameColumns(GalleryName.AllItems,"ID","EID"), /*Traverse all items in the gallery (including silverer5)*/
Patch(ProductCollect,LookUp( ProductCollect,ID=EID),{'Curent Quantity':'Curent Quantity'+Slider5.Value})
)

Best Regards,

Bof

View solution in original post

@v-bofeng-msft:

I appreciate your help so much!

 

Have an awesome day💪💪💪💪

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Users online (7,144)