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 / Command Bar Button Pat...
Power Apps
Answered

Command Bar Button Patch Logic

(1) ShareShare
ReportReport
Posted on by 802
Hi All have Patch Logic on a command button 
 
 
Patch(' XX Invoice Headers',Self.Selected.Item,{Transfer:true}) 
 
it appears to work for the first invoice I select in a session but if I try and do more than one it does not. It doesn't set the column value. Anyone ever see this before? Thx   
I have the same question (0)
  • Sunil Kumar Pashikanti Profile Picture
    1,619 Moderator on at
     
    Why it happens:
    Self.Selected.Item in command bars can become stale after the first execution. The Patch then runs but does not update the record.

    How to fix:
    Re‑resolve the record using LookUp, or use ForAll(Self.Selected.AllItems) for grids. Do not rely on Self.Selected.Item alone.
     
    Example fix:
    Patch(
        'XX Invoice Headers',
        LookUp(
            'XX Invoice Headers', 
            InvoiceHeaderID = Self.Selected.Item.InvoiceHeaderID
        ),
        { Transfer: true }
    )

    This is a known behavior and already discussed in the Power Platform Community.
    https://community.powerplatform.com/forums/thread/details/?threadid=abe5824e-a892-4def-b340-c02b8b571a6e

    Explanation:
    The Self.Selected.Item property in Command Bars often holds a cached version of the record from the moment the screen or control was initialized. If a user modifies a record and then immediately clicks a command bar button, Self.Selected.Item may still reflect the pre-modified state. This leads to a "silent failure" where the Patch executes but essentially overwrites the new data with the old cached data.
     
    By using a LookUp within the Patch function, you force Power Apps to fetch the most recent version of the record from the data source using its Primary ID. This bypasses the local cache.
     
    Using Self.Selected.AllItems is often more reliable because it references the collection of selected items currently held in the control’s buffer, which tends to be more reactive than the single Item property.
     
    ✅ If this answer helped resolve your issue, please mark it as Accepted so it can help others with the same problem.
    👍 Feel free to Like the post if you found it useful.
  • Suggested answer
    11manish Profile Picture
    1,169 on at
    In a command bar (modern commanding) in Power Apps:
    • Self.Selected.Item is not refreshed after the first Patch
    So:
    • First click → works 
    • Next clicks → use outdated record reference 
    Always re-fetch the record using its primary key and refresh the data source.
     
    Try below:
    Patch(
        'XX Invoice Headers',
        LookUp(
            'XX Invoice Headers',
            ID = Self.Selected.Item.ID
        ),
        { Transfer: true }
    );
    Refresh('XX Invoice Headers');
    The fix is:
    • Do not use Self.Selected.Item directly
    • Use LookUp() with the record ID
    • Add Refresh() after Patch
  • Suggested answer
    Valantis Profile Picture
    2,888 on at
     
    Agree with the answers above. Self.Selected.Item holds a cached reference after the first Patch which causes silent failures on subsequent clicks.
    The fix is to re-fetch the record via LookUp and add Refresh after:
    Patch(
        'XX Invoice Headers',
        LookUp('XX Invoice Headers', InvoiceHeaderID = Self.Selected.Item.InvoiceHeaderID),
        { Transfer: true }
    );
    Refresh('XX Invoice Headers')
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard