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( Patch)) Only u...
Power Apps
Unanswered

ForALL( Patch)) Only updates the first record

(0) ShareShare
ReportReport
Posted on by 85

Hi,

I feel I am close to solving this one however I need help getting over the line.  I have followed the principle that Shane Young used in his video https://www.youtube.com/watch?v=0xZ4fMJbLvk, however I do not want to use a checkbox.

I have a skills matrix and an individual employee will have multiple skills recorded.  If they change position or location etc I need to be able to update all of their records in the skills matrix. It only patches the first instance of the selected employee.

The first patch is to set the IsChosen to true and then patch the main record.

 

Patch(TeamCollection,GalleryTeamList.Selected, {IsChosen:true});

ForAll(
RenameColumns(Filter(TeamCollection,IsChosen),"EmployeeNumber","EmpNum"),
Patch(SkillsMatrix,LookUp(SkillsMatrix,EmployeeNumber=EmpNum),
{
Surname: AmendSurname.Text,
FirstName: AmendFirstName.Text,
Location: AmendLocation.Text,
Position: AmendPosition.Text
}
));

ClearCollect(TeamCollection,AddColumns(TeamList,"IsChosen",false));

Thanks in advance.

Categories:
I have the same question (0)
  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    @Fess67 

    Your first Patch() appears to update a column in a Collection called "IsChosen" to true for a selected Gallery item. Then, your ForAll() filters that collection based on IsChosen = true. Is this correct? If so, then your filter is only returning 1 record and that's why only 1 record gets updated.

     

    I'd suggest using a variable to do what you need here, like this:

    // create variable from selected Gallery item
    // add this code to your Gallery.OnSelect or any icons/labels you are using to do your first Patch
    Set(vEmpNum, GalleryTeamList.Selected.EmployeeNumber);
    
    // Patch updated info
    
    ForAll(
     // note, I assume you have a column called Skill, if not, change this to suit your field name
     RenameColumns(Filter(SkillsMatrix,EmployeeNumber=vEmpNum),"Skill","Skill_1"),
     UpdateIf(SkillsMatrix, Skill=Skill_1,
     {
     Surname: AmendSurname.Text,
     FirstName: AmendFirstName.Text,
     Location: AmendLocation.Text,
     Position: AmendPosition.Text
     }
     )
    );
    
    

    As I say, I assume you have a column called "Skill" and also that when you select a Gallery item you can access the EmployeeNumber that you need to reference. If this isn't correct, then you'll need to adjust your code to suit.

     

    I think that should do it? 

  • Fess67 Profile Picture
    85 on at

    Thanks for that, @Anonymous 

    I changed the code slightly as I was trying to have the EmployeeNumber as the constant and I can now change any other attribute about the individual and have it update all records in the matrix.

     

    I have a question about updateif.  I was avoiding that and trying to use patch as I though the updateif would run into delegation issues.  Is this going to fall over as soon as I add a decent number of records?

  • Community Power Platform Member Profile Picture
    on at

    @Fess67 

    Yes unfortunately, UpdateIf will eventually run into delegation issues but it may not affect your process if you are filtering the Skills of just one Employee? Surely an employee would need >2000 skills?

     

    However, if you end up updating more than just one employee there's a chance your function will be affected. Spend some time on future planning your data and functions and then use that to guide you on which way to go with it.

  • Fess67 Profile Picture
    85 on at

    Yes for this function I will only ever update 1 employee at a time and no, it is not likely that any employee will have more than 2000 'skills' although that is going to be something I have to manage with my managers as they think that passing a site induction is a 'skill' that needs to be recorded.

    Thanks for your help, much appreciated.  

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard