# Hiding a field based on role using a display formula

You can show and hide fields based on formula using JSONATA. For example, if you wanted to only show certain fields based on a setting or some value including role, use this formula:

```
user.highestRole = 'owner' or user.highestRole = 'author'
```

in the field settings

![](/files/F1Po5t41RgoxujX2RDzS)

Another example of this is

```
(user.highestRole = 'owner'  or user.highestRole = 'author')  or $not(user._id in viewers)
```

where `user._id` is the user ID of the current logged in user.

In that example, it checks that the user is an owner or author and is not a viewer , this provides additional flexibility to show/hide fields based on viewers, and current logged in user.

You could also check to see if the current user is the creator of the row with `user._id = userID` , where `userID` is the user ID of the the user who created the row and `user._id` is the currently logged in user.

Note, currently, hiding a field does not stop the data being sent to the client from the server. So the data is there, it’s just hidden. So do not use this for security. For security, you’d be better storing the secure data in a separate microapp, which controls the security correctly, and then use “cross app” fields to link them.

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.buzzy.buzz/the-building-blocks/datatables-fields-and-data/hiding-a-field-based-on-role-using-a-display-formula.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
