Hide / Reveal View based on Form Response

Application has Three views:

1. Home Screen (Onboarding): this is a starting view. 

2. Compose a response (Form View) 

3.  My response (Table View)

I would like My response (Table View) to be only accessible to users who have submitted a response through Compose a response (Table View). Logically, I would like Compose a response to stop being accessible to users who have submitted a response/filled out the form. 

In other words, what I am trying to accomplish is that a user fills out one form, and then can only revisit their answers for revision and improvement. 

I've used Show if formula before to accomplish similar things, and I hope Show if can be used to achieve the desired result in this situation as well. Thanks.

0 6 141
  • UX
6 REPLIES 6

It depends on the version of AppSheet you are using. You need to use at least the 'AppSheet Core' version.

If that's the case, first create a Data Slice view for 'My Response'. Then, in the 'Compose a Response' and 'My Response' views, adjust the 'Show If' condition based on whether the rows selected with USEREMAIL() using the SELECT() function are blank or not.

Thanks for your response @chansol! See, creating a condition is exactly where I struggle: I am not quite versed with the AppSheet syntax. Could you help me out here, please? Or point me in the direction where I should go and look. Thanks! 

Let's say I have a User table like this,

chansol_1-1707971173440.png

and a response table like this.

chansol_2-1707971204949.png

 

I'd give an initial value to the User ID column like: ANY(SELECT(User[User ID], [email] = USEREMAIL())).

If you finished setting the data, you have to first create a data slice - My response.

chansol_0-1707971116614.png

Condition to the data slice would be like: USEREMAIL() = ANY(SELECT(User[email], [_THISROW].[User ID] = [User ID])).

And I'd give the Form view's Show if condition like: ISBLANK(SELECT(response[Response ID], [User ID] = ANY(SELECT(User[User ID], USEREMAIL() = [email]))))

And My response view like: ISNOTBLANK(SELECT(response[Response ID], [User ID] = ANY(SELECT(User[User ID], USEREMAIL() = [email]))))

Thank you for your detailed response. 

What if I don't have a user table? Can I base your approach solely on the response table? If the AppSheet cannot find a user's response in the response table, it allows a user to submit a response. If it finds a user email in the response table, it allows the user to edit their response? 

Do I understand correctly that I need to create a user table? Or is there a way for the AppSheet to automatically populate this table when a user first signs into the app? 

 

 

AppSheet does not automatically populate the user table. I created the User table because it is a common use case.

However, you can do it without a user table. Actually, it's much easier.

In this case, the response table would look like this.

chansol_0-1707983589289.png

[User email]'s initial value will be: USEREMAIL().

The slice condition will be: USEREMAIL() = [User email].

Form view's Show if formula will be: ISBLANK(SELECT(response[Response ID], [User email] = USEREMAIL()))

and My response view: ISNOTBLANK(SELECT(response[Response ID], [User email] = USEREMAIL()))

 

Please try below

The record's initial value for the [Email] column should be USERAMIL() so that it captures the email of the person who added the record.

In the  system generated "Add" action of the "Responses" table , please add a condition in the action pane setting of "Only if this condition is true". The condition expression can be something like 

NOT(IN(USEREMAIL(),Responses[Email]))

Suvrutt_Gurjar_1-1707981972675.png

 

This will ensure that a user can add a record only if a record with her/his email in [Email] column of the "Responses" table does not exist.

For allowing a user to see only his or her single record , the security filter expression in the "Responses" table of [Email]=USEREMAIL() will help. This will make only respective record of a user visible to the respective user.

if a user can see all other records but edit only her or his own record, you could have an expression of [Email]=USEREMAIL() in the the action pane setting of "Only if this condition is true" of the system generated "Edit" action.

Edit: Made some changes to the description.

 

 

Top Labels in this Space