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 / Help with Patch and up...
Power Apps
Answered

Help with Patch and update context formula

(0) ShareShare
ReportReport
Posted on by 221

Hello,

      Can someone tell me what is wrong with my formula? 

 

UpdateContext(Patch('[incentive_test].[D_eTime]',
{ID: ThisItem.ID,
DELETE_IND: "Y",
MODIFY_USER: User().Email,
MODIFY_TIMESTAMP: Now()
}
),{DeletePopup:true})

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @NitroPepsi 

    Yes...UpdateContext is to set a context variable.

    The syntax is :  UpdateContext({ <variableName> : <value> })

     

    Are you trying to hold the record from your Patch in a variable, or just set the DeletePopup variable?

     

    If just setting the variable, then the formula should be:

    Patch('[incentive_test].[D_eTime]',
     {ID: ThisItem.ID,
     DELETE_IND: "Y",
     MODIFY_USER: User().Email,
     MODIFY_TIMESTAMP: Now()
     }
    );
    
    UpdateContext({DeletePopup:true})

     

    I hope this is helpful for you.

  • NitroPepsi Profile Picture
    221 on at

    Yes, setting up the variable. How do you know when it goes within the brackets and outside the brackets?

  • NitroPepsi Profile Picture
    221 on at

    I am setting up my variable for the popup to ask to delete the record when they press the trash icon. When they press the trash icon, I have two buttons pop up,  one is for "yes to delete" and the other is to "not delete". However, I do have an additional question, I have a patch on my delete icon, do I instead change the patch to the delete button instead of the trash icon?

     

    Patch('[incentive_test].[D_eTime]',
    {ID: ThisItem.ID,
    DELETE_IND: "Y",
    MODIFY_USER: User().Email,
    MODIFY_TIMESTAMP: Now()
    }
    );

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @NitroPepsi 

     

    JSON!!!  You don't have to know much about it, but knowing a little about a record and table definition in JSON is very helpful in PowerApps.

     

    Because - {name : value} is a JSON record.  In PowerApps, context variables are "merged/patched" into the context of the current screen.  The current screen really exists as a big ol' JSON data string.  SO...the UpdateContext wants to have a record to put in the context of the screen.

     

    So, knowing that record construct should indicate when and how to use it.  You will see that construct ALL over the place, because PowerApps is so deeply tied to JSON (it is what is underneath of everything).

     

    As for the Delete formula...if your trash can icon is going to pop up a question to "yes" or "no", then you don't want the delete formula on the icon...you want it on the Yes button.  The icon would only serve to activate the popup.  The Yes and No button would both deactivate the popup, but the Yes button would also perform the delete function (actually, I see you're not really deleting it, but simply tagging it as deleted.)

     

  • NitroPepsi Profile Picture
    221 on at

    Ok, I moved the patch function to the pop up ok delete button but it did not like it. The error it is giving me is the type argument ID does not match the expected number. Found type error. Function patch has invalid arguments. 

     

    Patch('[incentive_test].[D_eTime]',
    {ID: ThisItem.ID,
    DELETE_IND: "Y",
    MODIFY_USER: User().Email,
    MODIFY_TIMESTAMP: Now()
    }
    ); UpdateContext({DeletePopup:false})

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard