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
Solved! Go to Solution.
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
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( { ContextVariable: Value})
This would suggest that updating your context variable may be possible using:
UpdateContext ( { myContextVariable: "" } )
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
That seems to do the job. Thanks!
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())});
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
187 | |
53 | |
52 | |
38 | |
37 |
User | Count |
---|---|
282 | |
97 | |
86 | |
80 | |
77 |