Problem/Bug with CONTEXT()

When using CONTEXT() in security filters, the “Host” and “View” parameters doesn’t work correctly.

CONTEXT("Host") = "Server" returns TRUE when previewing the app in the emulator
CONTEXT("Host") = "Browser" returns FALSE when previewing the app in the emulator
CONTEXT("View") = "" returns TRUE when previewing the app in the emulator

The documentation states:

Host : Gives Browser if the app is running in a browser or the app editor’s emulator, Device if a native app, or Server if used from an AppSheet server (e.g., in a workflow or report).
View : The name of the view currently displayed to the user, or blank if no view is currently displayed (e.g., in a workflow or report).
CONTEXT() | AppSheet Help Center

If I understand it correctly, the reason behind this error is that the security filter is run on the AppSheet server, and not local on the device. But this limits the functionality, because I may want for instance to sync some records when using a phone app, and other records when using the browser. And the documentation doesnt state that is doesn’t work.

Any suggestions? :smiley: @Steve

Create usersettings using app formula of Context(host).
Then on your table security filter settings, use that user settings for slice condition.
Try it out.

Result of usersetting calculation is based on “client”
Then when user launch app, we are able to access this value, then use this value to filter your table on sync.


Aha, thanks for the tips! :smiley: Thats clever!
But that usersetting will not be set when for instance a workflow or report is running? If I want some rows to only be available when CONTEXT(“Host”)=“Server”, how can I do that?

On workflow (currenlty we call BOT) on event setting, you can turn on / off bypass filter.


Thats right! I am just used to still call them workflows :slight_smile:
I see that my explanation was sligtly off. I am triggering some actions via the Appsheet API from a webserver, and I want some rows to be available then, and thats why I would like the CONTEXT(“Host”) =“Server” to work in this instances. Becuase when running them from outside Appsheet, I am not able to bypass the filter. But I can choose which user to run it as, but I hoped to avoid to hard code what user in the web server routine.
But I have another workaround I can use :slight_smile: Thanks for helping!

But maybe it would be possible to warn users in the formula editor or documention that CONTEXT() in security filters may not work? :slight_smile:

I m not familiar with Context(host) = server, I never use in my app before.
But bypass security filter on/off settings couple with this technique should solve your own issue, I reckon.

1 Like

Your expectation tha the documentation identify every possibility that doesn’t work is unrealistic, if not absurd.

1 Like

Sorry! I did not mean to criticize! I just found this really hard to figure out my self, and thought it might be helpful to others.