FAQ: How do I do something automatically the first time someone uses my app?

Steve
Platinum 4
Platinum 4

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:

  1. Create a table or slice with exactly one row to serve as a menu for the new user.

  2. 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]))

  3. 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.

  4. Create a Grouped: execute a sequence of actions action for the table that performs both actions (2) & (3).

  5. Create a deck, gallery, or table view atop the table or slice (1) for the new user start view.

  6. Set the Row Selected event action for the new user start view (5) to the Grouped action (4).

  7. 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.

  8. 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:











24 22 4,307
22 REPLIES 22

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!!

elco
New Member

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!

  • That will totally work for what you want to do.

What @Steve did with this post is provide you with a complete list of steps needed to achieve the result.

  • If you already have the infrastructure needed to differentiate a user thatโ€™s new from a returning one, then you can skip over all those steps.

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

Just yesterday I had a client report to me that one of their users has 511 pending syncs on their device.

  • At some point last Friday, the user encountered an error; and instead of reporting it and trying to figure out whatโ€™s wrong, they kept working - racking up pending-sync after pending-sync, and only a week later (when the boss is wondering where all the data is) does the user say something.

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.

3X_7_7_77f9b90df8feac6376f4b0b4de43708625e340cc.png

โ€œ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:

matteolavaggi_0-1709292111536.png

matteolavaggi_1-1709292124514.pngmatteolavaggi_2-1709292134194.png

 

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.

Top Labels in this Space