Replace previous value saved in database with a new one

Hello, I need help, I’ve been stuck too long with this one so I decided to ask for helps.

I have a database field that will store/save user score every time user click on an answer.
value number 1 will be saved in the database field if the answer is right
value number 0 when its wrong. the default value is 0 too.

i want the program to replace the previous value with a new one. For example if the previous value is 1 and the latest answer is wrong, the value stored in database field will be updated and changed to 0.

Please help me guys, this is for my intern. LOL :smile:

You could do it this way

For when the answer is right

  • Make changes to a thing-current scores value + 1
  • Then when the answer is wrong you would do

Make changes to a thing-current scores value = 0

You could also use a custom state where it’s initial value is 0. When an answer is submitted and is correct you would add + 1 to that states value. Once the test is complete you would store the sum of the values in the database.

When it’s wrong you would just reset the state without storing the 0 in the database.

1 Like

Hello @AustinAllen , thank you for your reply, I appreciate it.

But, how do we exactly make changes to a values of a field?
I already tried it but it didn’t work. can you show me how it’s done?

I can set up a quick editor view for you when I get home but here’s how you can do it.
Here is the preview and editor Link

  • Create an input field and call it “input score” and set its type to number.

  • then create a button and label it as “submit”

  • click the start/edit workflow and choose “when an element is clicked”

  • under actions in the data tab you’ll see what changes you can do.

  • click on “make changes to a thing” and select the field to change to be “current score”

  • for the value you would put “input score’s” value

That would take whatever number is in that input and store it in the field you selected.

Thank you very much @AustinAllen , that helped me a lot.

have a great day