How to automatically add a new entry based on a column is true?

Hi. I am trying to build an app to record my watch's battery consumption. This contains 4 columns of the data: Key ID, Date, Recharge(a Yes/No data), Battery.

I like to enter the data daily; normally, there is only one entry each day. But when I have to recharge my watch, I need to input the [Current Battery](eg. 5%) and the [New Battery] (ie. 100%) after recharge. I would like to only input the [Current Battery]. Then a [New Battery] record could automatically be added to the app.

I tried to use Actions to achieve this feature. I chose:

[Effect: Data: add a new row to another table using values from this row]

[Set these columns] Key ID = Unqiueid(), Date = Today(), Recharge = No, Battery = 100%

[Position] Hide

[Behavior] Only if this condition is true: Recharge = Yes

And my trouble is, I cannot trigger this action when the Recharge = Yes. Am I misunderstanding the usage of [Action]? Or is there another method to achieve it?

Solved Solved
0 4 164
1 ACCEPTED SOLUTION

Action take place based on some user driven event or when specifically invoked by the user.

So if you are using a form to set the column [Recharge]="Yes", you could have your action that you have described as a 'Form Save" event action.

Run actions based on view events - AppSheet Help

Suvrutt_Gurjar_0-1732598823251.png

You need to include the action in the "Event Actions" Setting of the form view as the example screenshot shows below.

Suvrutt_Gurjar_1-1732598948236.png

 

 

 

 

 

View solution in original post

4 REPLIES 4

Action take place based on some user driven event or when specifically invoked by the user.

So if you are using a form to set the column [Recharge]="Yes", you could have your action that you have described as a 'Form Save" event action.

Run actions based on view events - AppSheet Help

Suvrutt_Gurjar_0-1732598823251.png

You need to include the action in the "Event Actions" Setting of the form view as the example screenshot shows below.

Suvrutt_Gurjar_1-1732598948236.png

 

 

 

 

 

Many thanks! This is so great to see the Action can triggered successfully after changing the Form Saved in the form views!

For those who might have the same issues as me, it is located in the System Generated under the Views.

systemGen.png

To set yourself up for success in the future, I advise adding in another action into the mix:

  • Save | Table_Name
  • A "Grouped: do a stack of actions" type of action

Put this as the actual action inside your form save event, and then put your action inside there.  Because I guarantee you'll want to add something else into that at some point;  you'll need to do something conditionally in the future to solve some problem, so you create another action (with the special condition) and put that inside your stack so it fires off too when the form saves.

By starting off with this save-stack action already in place, you're building a good habit that will make things easier for you down stream. 

Hope it helps!  Happy apping.

Thanks for your pro tip. Yes, it will be helpful when the app gets more and more complicated. 

 
Top Labels in this Space