cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kostaskoufos
Frequent Visitor

Patch all elements of a gallery

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions

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. 

View solution in original post

8 REPLIES 8
mdevaney
Super User III
Super User III

@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."

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.

@kostaskoufos 

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

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.

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

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. 

View solution in original post

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (12,304)