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 / Question about Context...
Power Apps
Answered

Question about Context Variables and Clearing an Object Data Type

(0) ShareShare
ReportReport
Posted on by 400

This is one of those weird questions where it may have already been discussed, but hidden behind unexpected subject terms. If this is the case, can you please supply a link? Thanks.

 

So I've been playing around with the idea of assigning objects to context variables (as well as collection fields). For example:

 

UpdateContext(myContextVariable, First(Filter(myCustomerSPList, ID=100)))

 

Once I've assigned myContextVariable to this item, I can refer to my customer as myContextVariable.FirstName. This is my intention. Now, I run some subsequent filters based on this data, so at some point, I'd like to clear out this data.

 

If I type in Clear(myContextVariable), I get an error because it's not a "collection" data type. If I type UpdateContext(myContextVariable, ""), I also get an error because it's not a "text"  data type. It's an "object" data type. How do you clear that? Thanks.

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-updatecontext

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi tommyly

     

    Interesting that your function below worked as well. 

    UpdateContext(myContextVariable, First(Filter(myCustomerSPList, ID=100)))

    I usually work with the following syntax as indicated in the documentation site you referred to: 

    UpdateContext( { ContextVariableValue})

     

    This would suggest that updating your context variable may be possible using:

    UpdateContext ( { myContextVariable: "" } )
  • Verified answer
    Scobie Profile Picture
    122 on at

    Hi @tommyly

     

    This was interesting as I hadn't thought much about a context variable being a object or record type. 

     

    To Clear this value for the vaiable you can make use of the Blank() function . As shown here:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-isblank-isempty

     

    using the syntax:

    UpdateContext({myContextVariable: Blank()})

     

    Scobie

  • tly Profile Picture
    400 on at

    That seems to do the job. Thanks!

  • salvadorplj Profile Picture
    9 on at

    The safest way to clear a variable is by being explit about the data type you hold in it, that way you wont have any issues if processes' steps intermix.


    Instead of:

    UpdateContext({SunShine: Blank()});

    Do: 

    UpdateContext({SunShine: DateTimeValue(Blank())});
  • Golly Profile Picture
    127 on at

    Be careful with setting variables to Blank()!  If you are storing a formula or strings with string interpolation in the variable, Blank() will store in the variable instead of clearing it, resulting in the variable clearing the value where you're using it.

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 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard