How do I setup/register a new app user automatically?
How can I do something automatically the first time a user uses the app?
This example assumes your app requires sign-in, and that you have a table named Users, each row of which describes a single user of your app. Such a table is a common way to store information about your app users and as an alternative to User Settings to store their individual app settings. The Users table is assumed to have a column named Email to store the email address each user uses to sign-in.
The process presented here does not replace the need for signed-in users to be registered as app users in the app editor.
If your app does not require sign-in, the best you can do is automatically detect a new device, which may or may not correspond to an individual user. Without user sign-in, you might have a Devices table instead of a Users table, and should use CONTEXT("Device")
rather than USEREMAIL()
.
Try this:
Create a table or slice with exactly one row to serve as a menu for the new user.
Create a Data: add a row to another table using values from this row action for the table (1) that adds a new row to your user table for the current user if the user is not currently in the user table, with an Only if this condition is true expression like: NOT(IN(USEREMAIL(), Users[Email]))
Create an App: go to another view in this app action for the table (1) with a Target expression that uses a LINKTOโฆ() function to navigate to a desirable starting view after the user addition.
Create a Grouped: execute a sequence of actions action for the table that performs both actions (2) & (3).
Create a deck, gallery, or table view atop the table or slice (1) for the new user start view.
Set the Row Selected event action for the new user start view (5) to the Grouped action (4).
Set the Starting view in UX >> Options to an expression that directs the user to the new user start view (5) if the current user is not currently in the user table, like:
IF(
NOT(IN(USEREMAIL(), Users[Email])),
"new-user-start-view",
"existing-user-start-view"
)
replacing new-user-start-view
with the name of the new user start view (5), and existing-user-start-view
with the name of a view existing users should see first.
Use Show if in all other views to hide them if the current user is not registered, to prevent the unregistered user from bypassing registration.
Sample apps:
See also:
You are always so thorough @Steve. I appreciate your work a lot.
Nice one @Steve. Tried the โWelcome New Userโ sample app. Very useful.
Thanks @Steveโฆ Very thoroughโฆ Great Use Caseโฆ Bookmarkedโฆ
Boom!
This will help a lot of new AppSheet users. Great job.
Outstanding as Always @Steve
Yo hice una aplicaciรณn que se conecta a las bases de datos de diferentes usuarios por cada movimiento que hacen me avisan si estan en linea o no
Nice!! Great Reference!! Thanks Steve!!
Why is this so much more complicated than just an if condition in starting view formula and 2 views to switch between?
Or letโs put it this way, why does this not work?
IFS(IN(USEREMAIL(), App Users[Email])=false, "App Users_Form", true, "Home")
The two views where โApp Users_Formโ is of type Form
with source set to App Users
table, and โHomeโ doesnโt matter.
Iโve run this in โTestโ mode and it returns the correct view name i.e. โApp Users_Formโ but app still goes to the middle tab by default.
Why must you memorise a list of steps on how a achieve such a simple thing (itโs an if condition people!?) Why canโt a new user just figure it out themselves?
Hello @elco; to answer in short, it does!
What @Steve did with this post is provide you with a complete list of steps needed to achieve the result.
Okay now Iโm more sad than mad. I donโt know why this doesnโt work.
Iโve tried in Incognito window where I had to login and I was lead to central tab (which is not the else choice in if condition). Does it perhaps cache which view user was on their last visit? Is there any other way to debug this further?
I know my email is not in the App Users[Email]
table column and like I said in test tab it shows correct result, but not on deployed version.
I see. I donโt understand but I see. I donโt need to now that you say my method should work
Indeedโฆ
Try:
If(NOT(IN(UserEmail(), App Users[Email])),
"App Users_Form",
"Home")
Thanks! That finally works (Sidenote: I didnโt know it takes a while for the deployed app to sync to latest version, it didnโt work for first few minutes and I almost reverted it back.)
But why? I donโt understand what the difference is between those two version? IN documentation says it returns FALSE
when element is not present.
Edit: Okay maybe early celebration, itโs quite erratic.
It works in IDE i.e. in the preview window but itโs stopped working on deployed version in browser even in incognito mode. On mobile doesnโt work either (how do you refresh the app sync doesnโt work?). I also would have thought that a manual sync would take you to โStarting Viewโ (but guess it makes sense sometimes not to either) so it never works when I do that.
Does anyone know exactly when this statement is evaluated i.e. โStarting viewโ? Everytime you open the app in a new tab or when you login? Any docs on this topic?
Thanks for the help but donโt wanna take over the thread; Iโll try contacting support this is crazy behavior!
There is certainly some sort of caching going on in the browser; even when I open link in new tab. When I go to any view and goto the app link w/o the #appName=Ello-2907772&group=%5B%5D&...
and it still goes to the last view open. This makes me thing it doesnโt evaluate the starting view condition otherview itโd either goto Home.
โThe first timeโ means the very first time the user opens the app, not whenever the user opens the app anew. The behavior of starting view has been changed since this community topic was created.
Performing a hard reload of the app editor (Shift+Ctrl+R) will cause the app emulator to behave as if starting your app the very first time. I think Save & Verify Data will, too.
Ah that explains it. Thanks a bunch.
So thereโs no way to force users to sign up when they first arrive to the app? They can โCancelโ the form and can continue to next view. This will also fail many filters/slices/formulae because they expect there to be a row with userโs email in the Users
table.
You could add a dummy row thatโs used when the current app user isnโt recognized. Send unrecognized users to that row, require them to do something with it, and withhold all other functionality until the current user is recognized.
@Steve Are your sample apps available anywhere at the moment? Getting not found at the moment. TIA
hi @Steve
When click to the link on Sample App section in your post, I've got 404 error.
Could you please update the links?
I've implemented the solution provided, but after some try when it work right, now it stop to work with no error message. Simply the action "add a new row to another table using values form this row" stop to being execute when click on the menรน icon. There is some way to debug the action fire mechanism?
There is some bheavior that i can't undestand with this approach:
1) i cant set a value of the column EMAIL of the users table in the action, i donw know why:
Maybe a simple approach is to use a My Account view, linked to users table, where "Add" action is only available if useremail() is not in the users[email] list.
My Account view can be set as default view for user.
Display name can be set on "My account" when email is in the users table or to signup when email is not in the users table. The only thing i cant change based on the status of users table is the icon. i Think is a better solution, more robust and simple than the other one.