web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / ForAll and Collections...
Power Apps
Answered

ForAll and Collections from Galleries

(0) ShareShare
ReportReport
Posted on by 517
Hi All,
 
the context:
Gallery2 (G2 - with text inputs) includes Gallery3 (G3 - with text inputs).
I want to collect both galleries in one collection.
Something like that:
 
 
The issue :
I can collect with the first ForAll() - colTicket but the second ForAll() - colSubTicket is empty.
 
Does anyone know how I can improve my code?
 
Thanks, dKayt
Categories:
I have the same question (0)
  • ronaldwalcott Profile Picture
    3,847 Moderator on at
    Where are you calling this code? Do you see any error messages?
  • dkayt Profile Picture
    517 on at
    Hey, 
    this code will be triggered from a button out of the gallery and I receive no error message.
  • Verified answer
    dkayt Profile Picture
    517 on at
    I do resolve it like this :
     
    CREATE MAIN TICKET
    -----------------------------
    ClearCollect(
        colTicket,
        {
            ID: If(
                IsBlank(Last(Sort(colTicketData, ID,SortOrder.Ascending)).ID),
                100,
                Last(Sort(colTicketData, ID, SortOrder.Ascending)).ID + 100
            ),
            SubID: 0,
            Unit: inp_Unit_2.Text,
            TicketNumber: TicketNumber_2.Text
        }
    );
    Collect(colTicketData, Sort(colTicket, ID, SortOrder.Ascending))
    
     
    SUB TICKET
    ----------------
    ClearCollect(
        colTicket,
        {
            ID: ThisItem.ID,
            SubID: If(
                Last(Sort(colTicketData, ID, SortOrder.Ascending)).SubID = 0,
                ThisItem.ID + 1,
                Last(Sort(colTicketData, ID, SortOrder.Ascending)).SubID + 1
            ),
            Unit: inp_Unit_2.Text,
            TicketNumber: TicketNumber_2.Text
        }
    );
    Collect(colTicketData, Sort(colTicket, ID, SortOrder.Ascending))
    
     
    SAVE
    -------
    If(
        IsError(
            ForAll(
                Gallery2_1.AllItems As G2,
                Patch(
                    TicketList,
                    Defaults(TicketList),
                    {
                        Unit: G2.inp_Unit_2.Text,
                        TicketNumber: G2.TicketNumber_2.Text
                    }
                )
            )
        ),
        NotificationType.Error,
        NotificationType.Success
    );
    Clear(colTicketData);
    
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 88

#2
WarrenBelz Profile Picture

WarrenBelz 85 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 45

Last 30 days Overall leaderboard