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 / Patch all elements of ...
Power Apps
Answered

Patch all elements of a gallery

(0) ShareShare
ReportReport
Posted on by 35

Hi All,

 

I'll put context to the problem I am encountering. I am developing an application to onboard users to the company. I have the record of the user onboarding, and a relation of One-To-Many with the tasks associated with that onboarding.

 

So I have two galleries:

- Gallery 1: shows the list of the next onboardings.

- Gallery 2: shows the list of the tasks associated with the selected onboarding of Gallery 1. 

 

In Gallery 1 I have a "Start" button that should modify the status of the Tasks in Gallery 2 from not started to Started. 

 

The formula of that button:

ForAll(RenameColumns('User tasks';"cr6cc_task";"RenamedTask"); Patch('User tasks'; LookUp('User tasks'; RenamedTask = Task);{Selected: true}))

 

I have seen the following video: https://www.youtube.com/watch?v=0xZ4fMJbLvk

and around the minute 22 he uses the same formula. It works for him, but the above formula doesn't work for me. Have the LookUp or ForAll lately?

 

I upload a photo to make things clearer.

 

patchallitems.png

 

 

Thanks in advance.

 

patchallitems.png
Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @kostaskoufos 

    The first thing that I noticed was your Patch contains this code to change the field "Selected"

    {Selected: true}

     

    But you said you wanted to change the Status instead.  So would this work?

    {Status: "Started"}

     

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • kostaskoufos Profile Picture
    35 on at

    Hi mdevaney,

     

    Thanks for pointing that out. When I went desperate I tried to simplify things by trying to modify a boolean field instead of the Status field (one multiset option I created).

     

    The problem still persist. 

     

    Best regards.

  • mdevaney Profile Picture
    29,993 Moderator on at

    @kostaskoufos 

    So which field do you want to modify then: Status or Selected?

  • kostaskoufos Profile Picture
    35 on at

    Hi again!

     

    Status is the one. The current formula is:

     

    ForAll(RenameColumns('User tasks';"cr6cc_task";"RenamedTask"); Patch('User tasks'; LookUp('User tasks'; RenamedTask = Task);{Status: [@Status].'In Progress'}))

     

    But that doesn't work. I don't really get it because it is the same formula the guy in the video uses, and it works for him.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @kostaskoufos ,

    Could you please share a bit more about your data source? Is it a CDS Entity?

    Is there something error message occurred when you execute the ForAll formula in your app? Could you please show more details about the formula you typed within the 

    Further, have you taken a try with the UpdateIf function to achieve your needs?

     

    Based on the formula that you mentioned, I could not find any syntax error with it. Please consider take a try with the following formula within your app:

    ForAll(
     RenameColumns(TasksGallery.AllItems; "cr6cc_task"; "RenamedTask");
     Patch(
     'User tasks';
     LookUp('User tasks'; Task = RenamedTask);
     {
     Status: [@Status].'In Progress'
     }
     )
    )

     

    In addition, you could also consider take a try with the following formula:

    UpdateIf(
     'User tasks',
     Task in TasksGallery.AllItems.Task,
     {
     Status: [@Status].'In Progress'
     }
    )

     

    Please consider take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • kostaskoufos Profile Picture
    35 on at

    Hi v-xida-msft,

     

    First of all thanks for your reply.

     

    I'll gladly share more info about my data structure. It is indeed all CDS entities based. For this situation I have:

    - Onboarding: main field is "Employee"

    - User tasks: includes a field "Onboarded employee"

     

    There is a relation 1 to N between Onboarding and User tasks. Therefore, there are multiple tasks related to one onboarding. 

     

    I have tested both formulas and neither of them work. I didn't know the UpdateIf statement so I have dove a little bit into it as it seems simpler than the ForAll + Patch statements. 

     

    I did what I believe is the simpliest thing of all: 

     

     

     

    UpdateIf(
     'User tasks';
     true;
     {
     Selected: true
     }
    )

     

     

     

    START.png

     

    If I got it right, this should update the "selected" field of all rows in the User tasks table. Still, Selected field doesn't change.

     

    This one is really being a bugger.

  • Verified answer
    kostaskoufos Profile Picture
    35 on at

    Hi again @v-xida-msft 

     

    I found the solution to my problem. The formula we were trying was fine, like in the video, but it works only outside the Task gallery. 

     

    LUNES20.png

     

    For the button inside the Gallery it displays a Delegation warning:

     

    delegation.png

     

    This delegation warning isn't shown when the button is outside the Gallery. I don't know if it is a bug or it is intended to work this way.

     

    Thanks to all that posted in this threqad. 

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @kostaskoufos ,

    Have you solved your problem?

     

    If you have solved your problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

     

    Best regards,

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 432 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 347

#3
WarrenBelz Profile Picture

WarrenBelz 254 Most Valuable Professional

Last 30 days Overall leaderboard