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

Repeating section

I have a functional repeating section that saves the values to SharePoint list.

nemanjasovic011_1-1659459798051.png

The issue is that I have to click '+' icon to populate the collection initially, otherwise - the collection is empty and nothing gets written to SharePoint when I click 'RPS_Test' button(submission to SharePoint). This will confuse the users. I am trying to avoid having to clicking the '+' to save the values in collection so that they can be pushed to SharePoint  IF the values are populated.  

 

Plus button has the following code:

Patch(
    RepeatingSection,
    ThisItem,
    {
        BottleSize123: BottleSizeMultiselect_2.Selected.Result,
        UPCComboBox:UPCComboBox2.Selected.Result,
        Other1:BottleSizeOtherRPTNEW.Text,
        Other2:UPCOtherRPC.Text
        
    }
);
Collect(
    RepeatingSection,
    {
        BottleSize123: "",
        Bottlesize2: "",
        Other1: "",
        Other2: ""
    }
);

RPS test button has the following code:

ForAll(
    RepeatingSection,
    If(
        !IsBlank(BottleSize123),
        (Patch(
            'Bottle Size UPS RS',
            Defaults('Bottle Size UPS RS'),
            {
                Title: "test",
                IDFK: 1,
                BottleSize: BottleSize123,
                BottleSizeOther: Other1,
                UPCOther: Other2,
                UPC: UPCComboBox
            }
        ) )
    )
)

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@nemanjasovic011 

You user interface is a little confusing then...you have a Plus (Add) icon in the row with the record you are editing.  Wouldn't it be less confusing to have a plus icon outside of the row - either on a blank row under any current ones or outside of the gallery?

 

Also, your ForAll is used backward.  You are using it like a For Loop in some development platform which PowerApps is not.  ForAll is a function that creates a table of records.  That can then be supplied to the Patch.  The way you have it currently, your app will have to instantiate a patch on each iteration rather than just once.  This will impact your performance greatly.

 

You are not mentioning how you are filling your collection, but in general, you need to not worry about all of that.

 

Concept is this:

- First, a collection used for the gallery.  That collection can be populated with a Filter of records from your datasource.  Or if you are always starting with no records, then it need not be created at all.

 

- Next, a "Plus/add" icon outside of the gallery that simply does the following:

Collect(RepeatingSection, Defaults('Bottle Size UPS RS'))

This will then show a new row in your gallery.

 

- Finally, your button to submit the records should be based on your Gallery...not the collection.

It would be more like this:

Patch('Bottle Size UPS RS',
    ForAll(
        Filter(yourGallery.AllItems, !IsBlank(BottleSize123InputControlName.<text/value/etc>)),
        {
            ID: ID,
            Title: "test",
            IDFK: 1,
            BottleSize: BottleSize123InputControlName.<text/value/etc>,
            BottleSizeOther: BottleSizeOtherInputControlName.<text/value/etc>,
            UPCOther: UPCOtherInputControlName.<text/value/etc>,
            UPC: UPCInputControlName.<text/value/etc>
        }
    ) 
)

 

That is all you need.  

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@nemanjasovic011 

You user interface is a little confusing then...you have a Plus (Add) icon in the row with the record you are editing.  Wouldn't it be less confusing to have a plus icon outside of the row - either on a blank row under any current ones or outside of the gallery?

 

Also, your ForAll is used backward.  You are using it like a For Loop in some development platform which PowerApps is not.  ForAll is a function that creates a table of records.  That can then be supplied to the Patch.  The way you have it currently, your app will have to instantiate a patch on each iteration rather than just once.  This will impact your performance greatly.

 

You are not mentioning how you are filling your collection, but in general, you need to not worry about all of that.

 

Concept is this:

- First, a collection used for the gallery.  That collection can be populated with a Filter of records from your datasource.  Or if you are always starting with no records, then it need not be created at all.

 

- Next, a "Plus/add" icon outside of the gallery that simply does the following:

Collect(RepeatingSection, Defaults('Bottle Size UPS RS'))

This will then show a new row in your gallery.

 

- Finally, your button to submit the records should be based on your Gallery...not the collection.

It would be more like this:

Patch('Bottle Size UPS RS',
    ForAll(
        Filter(yourGallery.AllItems, !IsBlank(BottleSize123InputControlName.<text/value/etc>)),
        {
            ID: ID,
            Title: "test",
            IDFK: 1,
            BottleSize: BottleSize123InputControlName.<text/value/etc>,
            BottleSizeOther: BottleSizeOtherInputControlName.<text/value/etc>,
            UPCOther: UPCOtherInputControlName.<text/value/etc>,
            UPC: UPCInputControlName.<text/value/etc>
        }
    ) 
)

 

That is all you need.  

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Moving + outside the repeating section, as per your instruction,  fixed the issue. Thank you.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,525)