How to apply show_if condition for a specific slice?

Hello everyone,

I'm encountering a problem that I believe should be easy to solve in any language, but I'm having some difficulty in AppSheet. I would like to know if anyone else has faced this problem and how they solved it.

Here's an example:

In my application, I have two views: GENERAL and TO_EDIT.

The GENERAL view is for admins to see all data, but in TO_EDIT, I want to apply some rules to display only certain columns. Both views have the same columns:

Photo, Date, Date, Responsible, Product_id

I want to display in TO_EDIT the Photo and Product_id columns only if the Date, Date, and Responsible columns are filled. However, when I apply a rule to show if it hides those columns in the entire app.

 

How can I solve this and limit this condition only to a specific slice or view?

0 2 33
2 REPLIES 2

1) Create a Virtual Column:

Go to your data table in the AppSheet editor.
Add a new virtual column, let's call it ShowPhotoProduct.
Use an expression to check if the Date, Date, and Responsible columns are filled. For example:

IF(ISNOTBLANK([Date]) AND ISNOTBLANK([Date2]) AND ISNOTBLANK([Responsible]), TRUE, FALSE)

This expression will return TRUE if all three columns (Date, Date2, Responsible) are filled, otherwise, it will return FALSE.

2) Set Visibility Conditions:

In your TO_EDIT view, go to the column settings for the Photo and Product_id columns.
Set the visibility condition to show the columns only when ShowPhotoProduct virtual column is TRUE.
For example, for the Photo column visibility condition:

Use

[ShowPhotoProduct]

The show if constraint in the datasource settings is quasi global, so if you have a constraint that makes this variable across your app, then you may need to implement a long winded formula for your specific use case. I personally have found that IFS() works relatively well to get this accomplished. Here is an example to possibly make this work for you, but it will likely require some additional tweaking since I am unfamiliar with all your requirements.

IFS(USERROLE() = "Admin", TRUE, AND(CONTEXT("View") = "TO_EDIT Form", ISNOTBLANK([Date]), ISNOTBLANK([Responsible])), TRUE, TRUE, FALSE)

Alternatively you can have different forms or detail views for slices or in general where you can use the 'Column Order' setting to designate which columns need to be displayed and in what order. You can also use actions with 'go to another view in this app' with IF()/IFS() formulas that attach to a table row click event that can take you to a separate view or dynamically determine the view to navigate to. Within Slices you can also manually check which columns need to be part of the slice. Short answer is use any/all of the above to make it work for your use case.

Top Labels in this Space