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

Notifications

Announcements

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 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 380 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 340

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 333 Super User 2025 Season 2

Last 30 days Overall leaderboard