cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BigJohn
Level: Powered On

PowerApps Gallery Button Passing Wrong Value to Flow

Hi,

 

I have a canvas app that connects to a CDS instance.

 

I have a gallery in which I have put a "Pick" button. 

When this is pressed, it uses Patch to update a value on the Account called "Picked" and also runs a Flow with the following: 

 

UpdateContext({pickedItem: ThisItem});
UpdateContext({patchResult: Patch([@Accounts], ThisItem, {Picked:currentUserEmail})});
If(Not(IsBlank(patchResult)) And IsEmpty(Errors([@Accounts])), Notify("Call Picked Successfully",NotificationType.Success),Notify("Error Picking Call", NotificationType.Error));
CreateAppointment.Run(ThisItem.Account);


The flow creates an Appointment based on the Account in ThisItem
Intermittently, the value passed into the flow isn't the correct Account, so the appointment is created for a different Account.

I can't find any reason, or any pattern as to why sometimes ThisItem, doesn't in fact contain the details of the Gallery item where the button is pressed for passing to the flow.

 

The Patch to the Account works fine every time.

 

I really hope that someone can point out what I've done wrong here, because it feels flaky at best.

 

Any help would be greatly appreciated.

 

Cheers...

 

John

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: PowerApps Gallery Button Passing Wrong Value to Flow

Hi @BigJohn,

If I'm understanding correctly:

  1. You update a record
  2. You run a flow based on the update
  3. Problem: you intermittently send the wrong account to the flow run

 

The issue here is that you are performing an update to a row in a gallery. The gallery reloads itself when the update is performed. My suggestion here is to use variables when you want content to be static.

 

It should be a quick fix in the last line. Instead of ThisItem.Account, point it to your variable patchResult:

CreateAppointment.Run(patchResult.Account);

 

This removes the formula's reliance on the gallery and points to the variable instead (more static). The variable will only change when you cause it to change whereas the gallery is changing as you have changed it in earlier steps. 

View solution in original post

3 REPLIES 3
Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: PowerApps Gallery Button Passing Wrong Value to Flow

Hi @BigJohn,

If I'm understanding correctly:

  1. You update a record
  2. You run a flow based on the update
  3. Problem: you intermittently send the wrong account to the flow run

 

The issue here is that you are performing an update to a row in a gallery. The gallery reloads itself when the update is performed. My suggestion here is to use variables when you want content to be static.

 

It should be a quick fix in the last line. Instead of ThisItem.Account, point it to your variable patchResult:

CreateAppointment.Run(patchResult.Account);

 

This removes the formula's reliance on the gallery and points to the variable instead (more static). The variable will only change when you cause it to change whereas the gallery is changing as you have changed it in earlier steps. 

View solution in original post

Community Support Team
Community Support Team

Re: PowerApps Gallery Button Passing Wrong Value to Flow

Hi @BigJohn ,

Could you tell me

1)the data type of Account field?

2)the parameter that you need in your CreateAppointment.Run function.

Based on your description, since Patch function could perform well,ThisItem should return right value.

So I think the problem should be in this formula:

CreateAppointment.Run(ThisItem.Account)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BigJohn
Level: Powered On

Re: PowerApps Gallery Button Passing Wrong Value to Flow

Thanks Mr Dang, I wasn't aware of the reload when an update was performed.

 

I've changed to a variable, and it appears to be working.

 

Thanks for your help.

 

John

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,901)