Forum Academy Marketplace Showcase Pricing Features

Button that generates numeric value for the user

Merry Christmas Bubblers.

I am trying to set a feature on my App which generates a numeric value for the specific user (say 3) each time the user clicks a button. When the user clicks on a button, it displays the value on the user’s dashboard and resets the button. When the user clicks on the button the second time, it adds that same value to the one initially allocated ie. 3+3. Users can only see points they generated and not points generated by other users. I tried using custom states but the problem I encountered is that the values generated disappear when the page is refreshed. I want the values generated by each user to be displayed on their dashboard each time they login. Any insights on how to set up this workflow will be greatly appreciated.

Hi there, @jpeangeles… if I understand your post correctly, I would probably add two fields to the User data type to accomplish what you have described.

The first field would store the numeric value that is generated for the specific user the first time the button is clicked. So, in your example, the user clicks the button the first time, and a workflow action saves a value of 3 to that field (from your description, it’s not clear how the value of 3 is being generated, but I’m guessing it might be randomly generated). The workflow action would have an only when condition on it that only saves a number to the field when the field is empty. With that condition in place, the field would only get a value the first time the button is clicked.

The second field would store a value that is the second field’s current value plus the number in the first field. So, when the button is clicked, the next step in the workflow (after the action described above) would simply add the first field’s value (3) to the existing value in the second field. With that action in place, the value in the second field would increment by 3 every time the button is clicked.

Any of that make sense? I hope so, and I hope it helps.


Thanks very much for your response Mike. I am trying to set it up but it’s not working for me. Would you mind attaching a screenshot which I can follow to set it up.

Sure thing. In my example, I have fields called generated num and cumulative num on the User data type. When a button called Button Update Number is clicked, the following workflow steps occur.

Note that the first step is generating a random 1-character string and then converting it to a number, and you would probably want to do something to make sure the generated number isn’t 0. As I mentioned, you didn’t clarify how you want to get the generated number, so I’m not sure how relevant that part of the example is.

Thank you Mike and sorry for not being clear enough on how the value will be generated. On how the value will be generated, I intend to allocate 3 when the button is clicked the first time and add another 3 each time the button is clicked e.g. if the button is clicked 4 times, the summation will be 12 (3+3+3+3). The idea is to allocate points to users each time they click on a button on their dashboard.

I followed the steps you provided but the points did not display - will appreciate your thoughts on the expression on the placeholder where the points will be displayed (maybe that is where i got it wrong). I have also attached the 3 screenshots.

In the text element, you should only need to display Current User's Points(2) because that field is going to increment every time the button is clicked.

Are you saying the number to increment by is always 3? For every user? All the time? If that is the case, then it’s even simpler. Delete the first workflow step (and you might as well delete the Points(1) field, too), and change the second workflow step (which will now be the first and only step) to be Points(2) = Current User's Points(2) + 3.

Thank you so much Mike, I have resolved the issue following the steps you advised. Is there anyway the values generated can be deleted at the back-end as they are not saved in the database?

Hmm, I’m not sure what you mean because the values are saved in the database. That being said, there are a number of ways you can clear the values. For example, you could have a backend workflow that makes changes to a list of users, and the change to make is to set the value of the Points(2) field to empty/blank. Then, you could run that workflow as a bulk operation, assuming you are on a paid plan, of course.

Thanks Mike, I have resolved the issue. Thanks a mill

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.