Hey Awesome People, I am trying out all the p...

(Ian Coldwell) #1

Hey Awesome People, I am trying out all the possibilities of AppSheet and was wondering if anyone had any experience in creating a user favorites table ?

That is, I would like an app user to be able to click a button on a list to add the item to a favorites list.

Any guidance would be very gratefully received.

Many thanks in advance. Ian

(Vivian Nowka-Keane) #2

Hi Ian, I have an idea about a way you could go about doing this: 1) Create a Yes/No column in the table called “favorite” with an initial value of “false” 2) Create an action called “Favorite” with the effect of “Data: set the value of a column” that sets “favorite” to true 3) Create a slice of the table with a row filter condition “[favorite]” 4) Create a view for that slice called “Favorites” Hope this helps!

(Gil Littman [AppSheet]) #3

I think the problem in @Vivian_Nowka-Keane’s approach (if I understood it correctly) is that all users will share the same favorites list.

Each row in the favorites table should contain the original item key, and the user’s email (assuming your app requires sign in). You want to protect this table with a security filter like USEREMAIL() = [email_column_name]. This way each user will see only his favorite items and also only his email address (!). Now you can create a slice for the items table filtering only items that appear in the favorites table.

(Ian Coldwell) #4

@Gil_Littman_AppSheet

This is great advice, Am I am able to implement and test this in pre-deployment mode with my own email address ?

(Gil Littman [AppSheet]) #5

@Ian_Coldwell Yes, you should be able to build and test it before deploying.

(Ian Coldwell) #6

@Gil_Littman_AppSheet

Hi Gill, I have been trying to add this action to my app but still need a little quidance… I have created a table called “favorites”. I have created a slice called “my_favorites”. I have added an “Add to my Favorites” action button the the detail view of the main list. So far so good ! My question is I can’t seem to find the way to tell the action button to add the row ( columns item key and USEREMAIL)to create a new row in the favorites table. Can you elaborate a little more about how to configure the action ?

Many many thanks … I feel like I am close :slight_smile:

(Gil Littman [AppSheet]) #7

@Ian_Coldwell You can set the action to go to another view in this app, and use LINKTOFORM to navigate to the right form and pre fill the the column item key. If you set the USEREMAIL to be the initial value of the email column, the user will only have to click save in that form.

(Vivian Nowka-Keane) #8

Hi Ian, If you have a Yes/No column called “favorites” and a slice called “my_favorites” and you filter with an expression like

“AND(USEREMAIL()=[email_col], [favorite_col])”, then a separate “favorites” table isn’t necessary. If you’re looking to add a row that is initially set to be a favorite, then you can create an “Add favorite” action that links to a form with pre-filled in values like Gil was saying.

To do this, you’ll need to create a ref view of type form for that table.

The expression for the action of type “App: go to another view within this app” would look something like LINKTOFORM(“FormName”, “true”, [favorite], USEREMAIL(), [email_col], UNIQUEID(), [key_col])