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

Collect custom text input fields from a gallery for all SP list items

Hi everyone,

I have spent the last 3 hours trying to figure these 2 hurdles out , hope someone can help me out.

 

I'm developing a requisition business process app, using a gallery to load a products catalog from a sharepoint list. I have added a textinput field for users to input the quantity needed, with the ability to add and remove within each list item.

 

However, I have a use case where a user wants to enter the quantity needed for the items, and add them all at once, instead of adding each item one at a time.

 

1- what code should I be using to collect all quantities at once?

2- how do I disable users from adding a product unless a quantity box has been filled?

3- For some reason, I'm unable to reset the quantity field when clicking on reset all, is there something wrong with my code?

For reference, please see codes and gif below.

 

SearchBox

OnChange = Set(searchQuery,SearchBox_1.Text)

 

GalleryDryItem

Items = Filter(Search(DryItems,searchQuery,"Product"),CLI.Value="Dryfood Items")

 

Add Button

OnSelect = If(IsBlank(LookUp(FINALorderlist,ID=ThisItem.ID,ID)),Collect(FINALorderlist,{ID:GalleryDryItem.Selected.ID, ProductName:GalleryDryItem.Selected.ProductName, Quantity:GalleryDryItem.Selected.QuantityBoxDryitems.Text, UOM:ThisItem.UoM}))

Visible = !IsBlank(LookUp(FINALorderlist,ID=ThisItem.ID,ID))

 

DisplayMode (Error, this isn't working)

DisplayMode = If(IsBlank(ThisItem.QuantityBoxDryitems.Text),DisplayMode.Disabled,DisplayMode.Edit)

 

Remove Button

OnSelect = RemoveIf(FINALorderlist,ID=ThisItem.ID);Reset(QuantityBoxDryitems)

Visible = !IsBlank(LookUp(FINALorderlist,ID=ThisItem.ID,ID))

 

 

powerapps.gif

 

 

I would be very grateful for the help. Thanks.

 

 

 

<<<Edit>>>

Solution for point 3 can be found here, thanks go to @RandyHayes for that.

https://powerusers.microsoft.com/t5/Building-Power-Apps/Filter-and-collect-SPList-with-a-custom-text... 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @radhi-bh ,

1)collect all quantities at once:
set the add all button's OnSelect:

ForAll(
       RenameColumns(GalleryDryItem,"ID","ID1"),
       Patch(FINALorderlist,LookUp(FINALorderlist,ID=ID1),
             {Quantity:QuantityBoxDryitems.Text}
            )
        )

2)disable users from adding a product unless a quantity box has been filled

set the add button's DisplayMode:

 If(IsBlank(ThisItem.Quantity),DisplayMode.Disabled,DisplayMode.Edit)

//justify based on field, not textinput

3)reset all:

Do you want to reset all the items' Quantity field?
If so, please set the reset all button's OnSelect:

ForAll(
       RenameColumns(GalleryDryItem,"ID","ID1"),
       Patch(FINALorderlist,LookUp(FINALorderlist,ID=ID1),
             {Quantity:Blank()}
            )
        )

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Community Support
Community Support

Hi @radhi-bh ,

1)collect all quantities at once:
set the add all button's OnSelect:

ForAll(
       RenameColumns(GalleryDryItem,"ID","ID1"),
       Patch(FINALorderlist,LookUp(FINALorderlist,ID=ID1),
             {Quantity:QuantityBoxDryitems.Text}
            )
        )

2)disable users from adding a product unless a quantity box has been filled

set the add button's DisplayMode:

 If(IsBlank(ThisItem.Quantity),DisplayMode.Disabled,DisplayMode.Edit)

//justify based on field, not textinput

3)reset all:

Do you want to reset all the items' Quantity field?
If so, please set the reset all button's OnSelect:

ForAll(
       RenameColumns(GalleryDryItem,"ID","ID1"),
       Patch(FINALorderlist,LookUp(FINALorderlist,ID=ID1),
             {Quantity:Blank()}
            )
        )

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi @v-yutliu-msft  thanks for your reply.

 

I'm sorry, I must first point out that this screen of the App is only capturing data into a collection, and not patching it into SP.

 

GalleryDryItem= SPlist
FINALorderlist = Collection
Orderlist = SPlist

 

1)collect all quantities at once into a collection "FINALorderlist", and only where QuantityBoxDryItems has a value. Right now, the only way users can add quantity into the collection is by clicking Add for each line item in the gallery.


the business use needed is a user entering all needed quantities into "QuantityBoxDryItems", and clicking a button to add them only into the "FINALorderlist" collection.


currently, when i click add all, it collects all items, even the ones where "QuantityBoxDryItems" is empty

 

2)disable users from adding a product unless a quantity box has been filled
set the add button's

 

DisplayMode:
If(IsBlank(ThisItem.Quantity),DisplayMode.Disabled,DisplayMode.Edit)

 

Thanks, this worked perfectly 🙂

 

3)reset all
For here, we're just looking to clear the Quantity textinput i.e. QuantityBoxDryItems Textinput within the gallery, and not SPlist. Upon clicking reset, the FINALorderlist collections gets cleared, but not the QuantityBoxDryItems

 

 

collectall.gif

 

Thanks for the help @v-yutliu-msft  , for the last bit to Add all, @RandyHayes helped me on it.

 

Posting the solution here in case someone stumbles on this one day.

 

https://powerusers.microsoft.com/t5/Building-Power-Apps/Filter-and-collect-SPList-with-a-custom-text... 

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
Top Kudoed Authors
Users online (9,100)