Button taking the user to step 1, 2 or 3 depending on if he already finished step 1 that day?

Hi guys,

I’m creating a daily journal where the user fills out the first steps/ questions of the journal in the morning and the last steps/questions in the evening.

My question is: How can I know if the user already created a journal on this day (filling out the first steps) so I can send him to the last questions of the journal or if he didn’t create any journal today and I can send him to create a new journal?

I’m thinking that if I create a property date/time field and a text field “State” on the journal, I would to be able to define the state being something like: Started, Finished allowing me to lead the user to either: 1. create a new journal, 2. take him to the last part of the existing journal and update it by writing out the last two questions or 3. if its now evening, take him to steps with adjusted questions in one flow.

But if this is the logic, how do I check in the database when tapping the Create Journal button if there is already created a journal today, so I can then look at that journal and check the state?

Would making a separate collection make a difference - simply to register and look up if the user created a journal today and what the state on that journals is?

Hope you are able to help with a solution that is performant, as this is a bit of a showstopper for me at the moment :slight_smile:

Thank you :pray:

Hi @Matt1,

Welcome to the forum!

Hint: have a look at “Count”. The logic could be the following:

  • add a button “Create Journal”, make it conditionally visible
  • visibility condition will be: Logged-in User → Journals → Count, where Created Date is between start of today and tomorrow
  • and count should be 0.

And for an existing today’s journal, create a list of Logged-in User → Journals, filtered by same Created Date filter:

Note: date/time comparison sometimes could be very glitchy in Adalo. The solution above should work, but if it doesn’t - the workaround will be to write the creation date in a separate text field, store current date (in the same format) in some property in logged-in user, and use these properties as a comparison criteria. But I hope you won’t need it :slight_smile:

Best,
Victor.

Hey @Victor

Thanks a lot for taking the time to reply with examples.

I tried adding the visibility logic to the button, but it doesnt seem to hide even though no journals have been created today. Deleting journals a few days back also doesnt make it invisible.

BUT the question is also if this will actually give me the result I’m trying to accomplish.
Let me draw out the use case:

Additional info:
A). The button the user taps today to start the journal is actually in the bottom navigation bar.
If that is problem I can move this to a button on the Home Screen. That would be okay.

B). The journal is created in the database and currently works - taking the user through the different steps updating the journal - in one flow. It is simply the part about dividing it into two steps, one in the morning and one in the evening and to a separate journey if he didn’t start the journal in the morning, that I havn’t solved.

So, The daily journal concept is the following:

  1. Every day the user writes down answers on defined questions in a daily journal. When the user taps the “Journal” button on the homescreen in the morning, we give him 3 questions to answer.

  2. When the user taps the same button (would be nice if the text change to eg. Finish Journal, but not crucial) again in the evening, we give him another 2 questions - updating the journal that he started that morning.

(In the last questions I’m fetching some information that the user defined in the morning, so I have to have access to the specific/current journal when the user comes back - both so that I can get that info but also just to update the current journal. How I access the Current Journal, when the user now comes back to the app, I dont know, as its not current anymore, but I would imagine there is just another way, like looking at the date or a state.)

  1. If the user should have forgotten to start the journal in the morning, and just comes in to do it in the evening, I will adjust the questions a bit and give him all in one proces (so just another path, with different screens).

SO, that was why I was thinking if it would help if there was a Finished (True/False) state on the journal, so we could maybe somehow make a logic like below and take the user to different views based on:

If user created journal Today is False > send him to the first questions.
If user created journal Today is True + Finished state is False, send him to the second questions to update current journal.
If user created journal Today is True + Finished state is True, send him to the view displaying the finished journal of today or hide the button.
If user created journal Today is False and Time is more than 4 pm > send him to flow with adjusted questions in one flow.

But how do we check if he created a journal today and how do we take the data from that current journal with us, when the user comes back to update it?

I hope I didn’t confuse with too much writing, just wanted to see if I can help :slight_smile:

Looking forward to your reply :pray:

Hi Again @Victor

I just closed the app and tried again and the first button now works, so tried implementing the second button you suggested and now see your logic :slight_smile: Great, thank you :pray:

To hide the second Update Journal button again from the home screen ones finished, I added a Done True / False property on the journal, and set the Update Journal button to only be seen, if the Done is false.

The App is loading a lot to display these different buttons and views, but maybe that’s just how it is.

Do you have any ideas for how to support the last step - that I want to take the user into another question flow if the time is later than lets say 4 pm for the users specific time zone?
I guess I could create a third button, like the first and somehow add the time criteria on this button and the first, so one is shown before 4 pm and one is shown after 4pm.
Is that the solution? And if so, how do I update the time on the user profile and will it work if I just manually write the time, like I’ve done it in this example - before/after 4:00 PM (on the profile it includes the date, so will it work to just write enough?)

Thank you :pray:

Hi @Matt1,

DateTime in Adalo is stored as a number of days from 1/1/1970, with the fraction representing “percentage” of the day. When displaying a datetime value, it is adjusted to a timezone of a user device.

E.g. 12:00 PM on 2nd of August in Athens (GMT+3) will be 19571.375:

  • 19571 is the number of days since 1/1/1970 till 2/8/2023
  • 0.5 is 12PM in GMT+0
  • subtract 0.125 is an adjustment for GMT+3 timezone - as in fact 12PM in Athens is 9AM in GMT+0.

So, if you would like to set some custom-defined “timestamp” for user in his timezone, you can:

  • add a variable to Users collection (datetime), call it “evening timestamp”
  • update Logged-in User → evening timestamp to a value of Start of Today + 0,66666666 (this will add 16 hours)
  • use this variable as a filter to show/hide additional button.
    Be sure not to update this variable too frequently to save app actions.

One of the possible options could be add the “evening opening timestamp” property to the Journal entry itself, populate it immediately upon creating a new entry, and use it as a filter. This will optimise the app actions usage, and also will make it easier to track correct flow for adding an entry.

Best,
Victor.

Hi @Victor

Thank you for your rapid reply.

1. Evening Time stamp, should just be updated ones, correct?
So how I first understood it was I should update the evening timestamp every time the user taps the Journal Entry, but I’m thinking that updating that timestamp every time is unnecessary, as we just need to define it ones, right? So what you mean must be just updating it one time - let’s say when the user taps the sign up button or something, simply to establish it, correct?

  1. Proporty not being updated
    So I created the Date/Time proporty on the user and added the action on a button, that should update that property with “Start of Today + 0,66666666”. But when tapping it, the proporty is not being updated on the user, so I must be missing something. If I leave out the + 0,66666666 the proporty is updated.

Is it because I should use one of the formulas when typing in the “Start of Today + 0,66666666”? (I havnt tried to use those, so not sure how they work.)

  1. Is this the last step
    And is it correct, that ones I managed to save the Evening Timestamp “Start of Today + 0,66666666” one time on the user, then I will just add a premise like this on the Create Journal, that takes the user to one flow or the other depending on if the current time is before or after the Evening Timestamp?

Thank you Viktor :slight_smile:

Update

I searched a bit more and came across your old video on the same topic

so decided to try to use this logic to save the current time on the user as I didn’t have luck saving the current time using the “Start of Today + 0,66666666”.

I had to update the user with the timestamp when he opens home, as adding it to the button along with the other logic, made it very slow to open, maybe because the system has to calculate more this way?

With this approach, loading the journal is quite slow, so do give me a heads up if the other approach is more performant and if so, how/where I should type in the “Start of Today + 0,66666666” for that data to be stored successfully :slight_smile:

Thanks again :pray:

@Matt1 sorry, I am not sure I understand what exact issue are you facing now and what would you like to achieve.

Let’s assume the following scenario:

  • your users should enter a journal entry every day
  • for each day, you would like your users to answer 1 question in general and 1 question after 4PM.

A possible way to achieve this:

  • create a collection of Journal Entries (or give it another name). Among other properties, this collection should have Answer1, Answer2, and datetime property where you’ll store the time when a user can submit Answer2 (call it A2CanPostAfter).
  • you set a button to “Add New Entry” using conditional visibility as discussed above. It should be visible only if there is no Entry for this Day (Entries → Count, where Created Date is between start of today and tomorrow, is equal to 0).
  • this button will create new Entry. Along with other things, it should also set a datetime parameter for A2CanPostAfter. You set this parameter as Start of Today + 0.66666666.

Result: when you create a new Entry, it you have the exact date and time when your user can post the 2nd answer for this exact Entry.

Then: when the entry is created, it is displayed using a list of Entries, filtered by logged-in user and datetime (between start of today and tomorrow). As a result, you will have just one list item to be displayed in this list - the created Entry for today.
This gives you a possibility to add a button into this list, and make it conditionally visible only when Current Time is later than Current Entry → A2CanPostAfter. And this button will lead a user to the Q2 flow.

Best,
Victor.

Hi @Victor

Thank you for your patience :slight_smile:

To correct the flow a bit. The use case is.

  1. (Morning): The user opens the journal entry, tapping button “Start todays journal”, answers 3 questions. Closes it
  2. (normally afternoon/evening): The user opens the journal entry, tapping button “finish todays journal”, finishes the last 2 questions of the journal, closes it.

Timestamp
*If the user didn’t answer the questions in the morning and he goes into do it in the afternoon, let’s say after 4 pm. I give him another flow where he answers an adjusted version of the questions, all in one.

I managed to do this and everything works. But to save the current time on the user, I had to use this approach logic Adalo experiments: conditional actions based on current time - YouTube.

For some reason saving the current time on the user, using the logic “Start of Today + 0,66666666” doesnt save the time on the user - so I was just curious what I did wrong when trying to save this data, as the proporty stays empty on the user. Maybe I should write it in some formula or something else for it to work? The proporty on the user is a date proporty.

It’s not crucial as I got it to work, but just curious if it might improve performance.

Thank you

Hi @Matt1,

Try to use . instead of ,

:slight_smile:
Best,
Victor.

Thank you @Victor :slight_smile: I will try using . instead :slight_smile:

1 Like

Hi @Victor

Do you by any change know why the timestamp doesn’t update on the user profile?

As I’m using this time stamp to adjust the Greeting message on the home screen as well depending on the time the user enters the app, I have set the action to update the timestamp on the user, when he opens home. But it doesnt update the property. It works fine if I add it to another page, but not on home. Any ideas why?


Thank you Victor :slight_smile: :pray:

It looked like it was a bug.
I could see there was an action on home set by Adalo to ask for Notification permission. Once I moved that action below my own action, my own action now started working.
I guess their action shouldnt block mine, but looks like it did.

So problem is solved :slight_smile:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.