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

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
    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

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard