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

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:

18 Likes

You are always so thorough @Steve. I appreciate your work a lot.

6 Likes

Nice one @Steve. Tried the ā€œWelcome New Userā€ sample app. Very useful.

2 Likes

Thanks @Steve… Very thorough… Great Use Case… Bookmarked…

2 Likes

Boom!

1 Like

This will help a lot of new AppSheet users. Great job.

1 Like

Outstanding as Always @Steve

1 Like

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

2 Likes

Nice!! Great Reference!! Thanks Steve!!

2 Likes

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?

elco:

Or let’s put it this way, why does this not work?> > auto> IFS(IN(USEREMAIL(), App Users[Email])=false, "App Users_Form", true, "Home")> >

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

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.

elco:

Why can’t a new user just figure it out themselves?

Indeed…

2 Likes

MultiTech_Visions:

That will totally work for what you want to do.

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.

MultiTech_Visions:

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

I see. I don’t understand but I see. I don’t need to now that you say my method should work

1 Like

elco:

IFS(IN(USEREMAIL(), App Users[Email])=false, "App Users_Form", true, "Home")

Try:

If(NOT(IN(UserEmail(), App Users[Email])), 
  "App Users_Form", 
"Home")

3 Likes

MultiTech_Visions:

Try:> > auto> 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.

5 Likes

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.

1 Like

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.

1 Like

@Steve Are your sample apps available anywhere at the moment? Getting not found at the moment. TIA

1 Like

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?

1 Like