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 / PowerApps Gallery Butt...
Power Apps
Answered

PowerApps Gallery Button Passing Wrong Value to Flow

(0) ShareShare
ReportReport
Posted on by 54

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

Categories:
I have the same question (0)
  • Verified answer
    Mr-Dang-MSFT Profile Picture
    on at

    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. 

  • v-yutliu-msft Profile Picture
    on at

    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,

  • BigJohn Profile Picture
    54 on at

    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

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard