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

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch related table wi...
Power Apps
Unanswered

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?
Categories:
I have the same question (0)
  • Suggested answer
    SwatiSTW Profile Picture
    741 Super User 2025 Season 2 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

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 757 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 322 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 209 Super User 2025 Season 2

Last 30 days Overall leaderboard