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

Help with Nested Galleries

I have a screen in an app with the following on the OnStart

 

ClearCollect(
    finalizeSchedule,
        Filter(
            weeklySchedule,
            DateValue(Start_x0020_Date) >= sundayDate,
            DateValue(Start_x0020_Date) <= (sundayDate + 7),
            Weekly_x0020_Status <> "Completed",
            Title in currentTrainees.Title
        )
)

 

 

Then i have a nested gallery with this set to Items

 

With(
    {
        records: Sort(
            GroupBy(
                AddColumns(
                    finalizeSchedule,
                    "mondayDate",
                    If(
                        'Start Date' <> "TBD",
                        (Text(
                            DateAdd(
                                DateValue('Start Date'),
                                If(
                                    Weekday(DateValue('Start Date')) = 1,
                                    1,
                                    Weekday(DateValue('Start Date')) = 2,
                                    0,
                                    Weekday(DateValue('Start Date')) = 3,
                                    -1,
                                    Weekday(DateValue('Start Date')) = 4,
                                    -2,
                                    Weekday(DateValue('Start Date')) = 5,
                                    -3,
                                    Weekday(DateValue('Start Date')) = 6,
                                    -4,
                                    Weekday(DateValue('Start Date')) = 7,
                                    -5
                                )
                            ),
                            "mm/dd/yyyy"
                        )),
                        "Not Scheduled"
                    )
                ),
                "Title",
                "mondayDate",
                "DATA"
            ),
            Title
        )
    },
    ForAll(
        Sequence(CountRows(records)),
        Patch(
            Last(
                FirstN(
                    records,
                    Value
                )
            ),
            {rowNumber: Value}
        )
    )
)

 

 

scriptjet_0-1627591318856.png

What I need to do is have a submit button outside the gallery that patches the dropdown to a column in the original collection I made on the OnStart of this screen.

 

Not sure if its because I've been looking at this for 2 days now and am brain dead, or I'm just an idiot.


Any help is greatly appreciated.

4 REPLIES 4
WarrenBelz
Super User III
Super User III

Hi @scriptjet ,

Firstly, I can optimise the Items a bit for you

With(
   {
      records: 
      Sort(
         GroupBy(
            AddColumns(
               finalizeSchedule,
               "mondayDate",
               If(
                  'Start Date' <> "TBD",
                  Text(
                     DateAdd(
                        DateValue('Start Date'),
                        -Weekday(DateValue('Start Date'),MondayZero),
                        "mm/dd/yyyy"
                     ),
                     "Not Scheduled"
                  )
               )
			),
            "Title",
            "mondayDate",
            "DATA"
         ),
         Title
      )
   },
   ForAll(
      Sequence(CountRows(records)),
      Patch(
         Last(
            FirstN(
               records,
               Value
            )
         ),
         {rowNumber: Value}
      )
   )
)

To send back to the list

ForAll(
   GalleryName.AllItems As aPatch,
   Patch(
      finalizeSchedule,
      {ID:aPatch.ID},
      {FieldName:aPatch.dropdownname.Selected.xxxx}
   )
)

xxxx being the valid output of the dropdown

 

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.

Thanks for the optimized code, worked great.

 

Still not getting anything on the Patch to the original finalizedSchedule collection.

 

I put in an iterator in the code you provided just to see what's happening, it it doesn't appear to be working through the inner galleries as intended.

 

Thoughts?

 

ForAll(
    innerGallery.AllItems As aPatch,
    Patch(iterator,{iterator: First(iterator).iterator + 1});
    Collect(
        testCol,
        {ID: First(iterator).iterator}
    )
);

I keep getting an empty collection when I run this.

Hi @scriptjet ,

This seems unrelated to your post - what exactly is the structure of iterator and how does it relate to the field in the gallery? You might explain in a bit more detail exactly what you are trying to do with this code.

I just did the iterator to see if it was reading anything from the inner gallery, which it is not.  I did the test because I wasn't getting anything from your original suggestion.

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,938)