Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Error Handling
Suggested answer

Patch related table with collection from another table.

(0) ShareShare
ReportReport
Posted on by
I have 3 tables - Employee, EmployeeSoftware, Software. Employee and Software have a one-to-many relationship with EmployeeSoftware and it is intended to be a bridge table. In my canvas app, I am creating a collection based on the software that is selected in a gallery. (gallery displays all software) I have a submit button that would ideally patch each selected Software and Employee to the EmployeeSoftware table. However, when trying to use a ForAll(collection, I get an error that EmployeeSoftwares is not accessible in this context.  
 
ForAll(SelectedItems,
Patch('EmployeeSoftwares', Defaults(EmployeeSoftwares) ....
 
 
Is there a better way I could achieve this outcome or how could I make the collection patch to a seperate table?
  • Suggested answer
    SwatiSTW Profile Picture
    592 Super User 2025 Season 1 on at
    Patch related table with collection from another table.
    The error "EmployeeSoftwares is not accessible in this context" usually occurs because this table might not be recognized in the context of the ForAll function or this table might not be properly added as a data source in your app. Try below solutions
    1. Ensure EmployeeSoftwares is added as a data source in your app
    2. Create a collection to store the selected software items. Assume you are working with a gallery named GallerySoftware, and it has a checkbox for selection.
    ClearCollect(
        SelectedItems,
        Filter(GallerySoftware.AllItems, CheckboxSelected.Value)
    );
    3. Store the currently selected employee in a variable. For example, if the current employee is determined by the logged-in user
    Set(
        CurrentEmployee,
        LookUp(Employees, Email = User().Email)
    );
    4. Use ForAll to loop through the collection and patch each selected software to the EmployeeSoftwares table. Use explicit field references to avoid ambiguity.
    ForAll(
        SelectedItems,
        Patch(
            EmployeeSoftwares,
            Defaults(EmployeeSoftwares),
            {
                Employee: CurrentEmployee,
                Software: ThisRecord
            }
        )
    );

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1

Featured topics