How to move to the next item/day in a database

Hi! I currently have a task list that checks if the items listed have been completed in their entirety. I also have a text component above that currently displays the task list day. (ex. Day 1) that populates from my database based upon the user and their progress. How can I get the text component (Day 1) to change to the next day (Day 2) from the database once I click a Submit button? Thanks!

In short, I guess I’m asking, how can I change and update an item in my database to reflect the next day?

Umm, this will depend a lot on your data structure really :thinking: For that you need to evaluate whether you will create a data table of dates or tasks. I would probably go with tasks, but then it would be important that your database would allow querying with a limit on the date, so you can ask for the tasks of the day etc…

Aside from that, you can find our date formula functions here. You will need to use formulas to increment the date to get it right, e.g. ADD_DURATION.

Thanks @Mevi

I have attached my Tasks table below.
image

Currently, I have a submit button that validates if both boxes are checked. If not, I throw an alert message.

Also, where highlighted I populate the “Day 1” from an app variable.

The app variable is set during the user Log In

And the value comes from the TaskDay field in the motivation table
image

I would like the motivation_id to change to Day 2 in the user table when the Submit button is clicked properly.

I’m currently stuck here. Can you provide any assistance? Thank you!

Ah so it’s not a date-type field at all, but a String/text type. I recommend to just switch the TaskDay to a number type field, so it would just be 1, 2, 3, etc. You can add the “Day” text to it in Composer where needed. When it’s a number type field, it’s easy to update it to be +1.

Hi @Mevi
I have a MOTIVATION table where I have a text type named TaskDay.
image

I also have a USER table with the motivation_id represented as an integer in my database where I retrieve the TaskDay based on the users Login.


image

Currently I have an APP VARIABLE named TaskDay set with a text value

My Text field gets its value from there.

I set the TaskDay app variable at Login and Get Record from another node using _user_motivation.TaskDay

I’m not trying to increment the actual number only, I would like to change the motivation_id in the USER table to the next TaskDay ID (Day 2 #2).
image

Only because I have a motivational quote associated with each TaskDay that gets referenced elsewhere in my app.
image

When all checkboxes are checked and the Submit button is clicked that is when I expect the change. As shown with the If condition formula below:
image

If condition
((data.Tasks1[0].CheckedTask) && (data.Tasks1[1].CheckedTask))

Any idea how I could accomplish this? Thanks!

So… Looking at it the id of day 2 is 2, and the motivation_id field is of integer type, so why would you not be able to just update it with a +1? Use SET_KEY and set the motivation_id to be user.motivation_id+1.

For finding the correct motivational quote for the id, use LOOKUP to get the motivation_id from the user and then use that id to FIND the correct motivation, using LOOKUP again to get the quote.

Thanks for your help @Mari! I understand what you mean, seems simple enough but actually implementing it is another story. Being a novice, I spent most of the day trying to figure it out, but I’ll keep trying. Thanks again!

1 Like

Hi @Mevi ! I tried using the SET_KEY with the examples you provided but SET_KEY says it requires 3 parameters to work properly. I tried inserting different things within a formula, but I keep using the wrong objects/parameters or the text/number conflict remains. I’m trying to update the database record for the user to the next record in the database after clicking the submit button. I believe if I can just accomplish this everything else is in place to work successfully. I don’t understand how I can use the text assigned to the id number rather than the number itself, but I need the number to increment to the next record, correct? At a loss for the moment. Can you provide any other advice? Thanks!

If you get confused by how to use a Formula, check the examples either from the formula editor or from the docs!

So with SET_KEY, the formula you need is something like SET_KEY([the data resource you're setting in USER table, e.g. appVars.currentUser or however you store it], "motivation_id", "Day " + NUMBER(PICK_ITEM(SPLIT(appVars.currentUser.motivation_id, " "), 1))+1) … or something