Quick Update System - How to update records in your app with a push of a button

“How can I update a parent record when a child record is changed?”
“How can I mark all the line items in an invoice as paid when I mark the invoice as paid?”
“If I have App Formulas inside a physical column, how can I get those to update like a virtual column?”
“How can I recalculate formulas with a push of a button?”

All of these situations can be solved by implementing a Quick Update System inside your app.


What is the Quick Update System?

A way to update app formulas and recalculate values on the fly.

How does it work?

Through the fact that updating any value inside a record in an AppSheet app will cause ALL formulas on that row to recalculate (physical & virtual columns both).

What does it take to implement?

  1. A hidden column of the number type
  2. An action to add 1 to the current value of that column
    • [Update_Column] + 1
A note on Naming Conventions

Once you start implementing systems like this, you can easily end up with hundreds of actions that you have to look through to find what you’re trying to fix or work with. The search feature is helpful, but to make things even easier it’s handy to adopt a naming convention.

My naming convention for Update actions is the following

  • Update | Name_Of_Table

3X_7_a_7ade9f78c47551068956c2d737cd4d643c6e5b8c.png

My naming convention for reference update actions

  • Ref Update | Triggering_Table > Updating_Table

 

 



What else can this system be used for?

Once you have this system in place in all the tables in your app (that need updating like this), you can utilize reference actions to update large sets of records all at once.


Update All Child Records

You can easily update all the child records from a parent-child relationship inside your app

All you have to do is create a reference action that runs the update action over the [Related Child_Records] column.

What do I do when I’ve got more than one related table to update?

When you’ve got more than one [Related Whatever] column (and associated tables) that you need to update, the process is relatively the same - you just have to add in a composite action into the mix.


Update Parent from Child Record

Working in the opposite direction from the example above, you can utilize the exact same ref-update system to update a PARENT record from the child.

Setup is almost exactly the same (you can copy the same Ref Update action and just change a few things to speed things up).


Update Flagged Records

If you include an additional column in your tables that will allow you to flag columns in such a way, you can create a slice to pull those records out and a corresponding reference action that runs the update action only on that subset.

This is nice when you’ve got records or data that you need to upload into the system (and you’re not wanting to utilize the CSV upload feature);

  • You can copy/paste your data directly into the table, with that flag I mentioned earlier set so these records are held in that slice, then run your update action over them with a single button push.


CRITICAL NOTE TO UNDERSTAND ABOUT BOTS

Update actions called through a bot WILL LIKELY NOT update the app formulas for the row

  • The only data change that happens is the [Update] column’s value increasing by one.

The true functionality for the AppSheet system is “supposed to” update ALL app formulas when you change data from a bot's task - but in practice, more often than not, it’s as I describe above and only the actual [Update] number changes.

I call these bugs "see-saw bugs" - it's prone to “breaking” and reverting back to the functionality I’m describing here; they fix it, but eventually it breaks again. I’d rather assume it’s broken all the time and this is how things function. I’m content to work within the constraints of something that will be reliable and constant in it’s behavior, vs building something that MIGHT work or might not.)

I find that if I keep the updates inside the app - utilizing the actions described above - I have no problems with things updating.


46 48 10.2K
48 REPLIES 48

Matt the visionary has done it again ! thank you, i’ll send anyone asking update-related questions straight to this post.

Oh man, that’s a bummer for sure, i’ve got some changes to make then, thanks for the heads up ! 2X_f_f1b7811ad56eba8f9fd50a81511eb6bd33a36ef4.gif

I’m not sure I agree with the top statement. So, far I have not seen an issue where an App Formula was supposed to update a value and didn’t.

It should be made clear that App Formulas in OTHER rows (e.g. a parent row) will not fire even though they depend on the row being changed. Those OTHER rows must be “touched” (i.e. edited) in order for its App Formulas to update.

Taking the bottom statement as the expected behavior, we should implement our systems with that expectation and when it doesn’t happen open it as a bug to AppSheet to address the issue. Workflows are extremely important functionalities. They and all the bits and bobs should just work!

Thank you Matt for another cool trick! I’ve been studying this for a while now & would like to ask…
If I wanted to Set the ‘Status’ values on the child table [Related_Line Items], how would you recommend I do this? Can I add my ([Status]=“In Progress”) in with the existing ([Update]+1) Action or should I create a new Action to Set other columns & then composite them all within the Ref Update?

Thanks also for the tips on your naming system… I’ll be using this from now on to help keep me organised

The action used for this update system should be kept isolated by itself;

  • this way when you need to “update the record” you can easily call the update action and have confidence that it’s not going to do anything else.

If you need to “update a record” in addition to doing something else, that’s what composite actions are for.


For this sort of interaction, @Brand-It I have to first ask:

  • Are you essentially “copying” the status of the parent into each of the child records?

If so, why copy that data there - it’s already present on the parent level.


But to answer your questions directly:

  • You’ll need to make use of a ref action to update the [Related Child Records] from the parent;
    • but instead of the “update” action, create your own action that sets the [Status] column to whatever value.

Ok, thats what I thought so just keep the Update actions to [Update]+1 on their own.

What caught my attention at the start of your post was “How can I mark all the line items in an invoice as paid when I mark the invoice as paid?”. I find that I can have several uses for doing this sort of action or something similar.

What I’m trying to do is when I ‘confirm’(action) an Order from the orders Table, I also want to update the Status of all the [Related Order Details] to “Work Order Created”.

I can see that you ‘very cleverly’ use the [Related_Whatever] columns to Update the child records & LIST([Ref_Col] to Update the Parent tables & so I was just trying to use these techniques in my apps.

Am I right in thinking that the ‘Quick Update’ is best used for Tables that already have App Formulas inside?

I’m still a ‘White Belt’ in the Appsheet Arts

Thanks for the help!

3X_4_6_4622279e00e00d9eaeccee7535e84a715d7b9433.png

Yes, that’s exactly what they were intended for.

For the scenario I’m talking about here, what I did was create a field that had an App Formula that contained logic to check various fields and data to determine the status of something - then all you have to do is call the update action on the child records, and all their [Status] fields will update.

Wait… so you’re storing the status of the parent… on each of the child records?

Why not just suffice with that data on the parent level? What purpose does it serve having that on the child level?

You might check out “data normalization” as it’s something very helpful to know when developing your data schema.

Well, my ‘Order Details’ (Child) also holds a job specification on each row. It is used for the “Quotation” to begin with then, when the status changes to [Status]=“Work Order Created” it becomes the specification for a copied instance of a new 'Work Order".
I use this “Work Order Created” change, to filter out the data in my “Work Order Request” valid_if column.

I’ve been using ideas from Ty’s “Medical Tasks” workflow sample app where I can create a new work order with all the associated Tasks attached.

Anyway I don’t want to hijack this post with my issues! Lol

Really cool. Thank you @MultiTech_Visions !

This tutorial would have saved me a lot of time when I looked into that. I ended up creating a Date field that I updated with NOW() to refresh the record’s fields and keep a log on when it happened.

I did try to use Workflow in some instances but that did not work for me as it was too slow.

Just WOW!

BUT, I have an app for freelancers to create jobs FIRST and then creating a weekly Jobs List.

The way I used to do it is by having a VC in the Jobs table with the formula

Lookup([_THISROW].[WeekNum],Jobs Lists,“WeekNum”,ID)

I have tried the Update system but if the related column in the parent table (Jobs Lists) is a VC, it works, if it’s a physical one, the update action doesn’t work anymore.

That is the only change I have made again and again and with it being VC, works, Update column gets +1, with physical, it doesn’t.

I have checked the related columns to be ref.

ideas?

Got it!

Because at the time I want to run the action, the child’s ref column is blank.
The parent record was not created so there is no relationship between them just after the parent is created.

I have solved it by using the next formula in the parent update action for related records

SELECT(Jobs[ID],ISBLANK([Job List]))

I love this magic… thank you @MultiTech_Visions

Update Parent from Child Record

Working in the opposite direction from the example above, you can utilize the exact same ref-update system to update a PARENT record from the child.
Setup is almost exactly the same (you can copy the same Ref Update action and just change a few things to speed things up).

Is there a way to, instead of changing the value for a fixed value ( in this case +1), changing it with the value of another form?

For example: I have a form being filled. I’d like that the value of some column that feeds table A to change the value of certain columns in table B. Both summing or deducing from its value.

Regards;

Fábio.

Sounds like a perfect case for the quick update system.

You’ll need to use an app formula to “sum and deduce” - it’s from the quick update that we cause those formulas to update.

Thanks for your reply.

I’ve been trying it for a long time, and still can’t find a way to make it work.

This part is already done. Although I can’t find anywhere some path to follow in order to change the value of a parent column with the value of the child table.

For example:

  • [Update_Column] + 1
    if you wanted to change the value of the [Update_Column], instead of +1, make the below change:
    [Update_Column] + The value of the child row being input in the child form,

Is there a way to do so?

Truly appreciate your help .

Regards;

Fábio

AY2450
New Member

Thankyou - just what I was looking for …LEGEND

Ami
Bronze 5
Bronze 5

Hi

What if i want to run the update on all the rows of my parent table from my parent table? What do i ref in the sequence action? Is using LIST([_THISROW]) ok?

Hey @1111

Essentially what you’re saying here is you want to update every row in the parent table, and you can accomplish this by simply calling every record from that table:

Table[TableKey]

I am able to update 1 row at a time but I want to update all rows in the table when we click the button.
Please let me know how to do this. Thank You!

Hello @Total_Solutions, please see the section above:

The method is the same as that, but instead of passing the [Related Whatever] column into the “Referenced Rows” space, you instead pass it the table you wish to update:

  • Specifying the appropriate table (in the “Referenced Table” dropdown) and the associated Update action (in the “Referenced Action” dropdown.

Thank You!

Thaks,

Can you update records automatically, without using a button?
Maybe using bots?

Of course you can!

  • Any action you run by pressing it, can be done via automation.

    • Keep in mind though, that these updates are made server-side, so your users will have to wait for a sync to happen in order to get the results

      • Versus doing all the updates client-side via actions.

This is the system you need to put in place in order to accomplish the effect of being able to “quick update” a record; how you execute the action doesn’t matter.

For anyone looking to update a Parent record from the Child:

Hi @MultiTech (Matt),

Thanks so much for this. One question: how about when deleting a child record? Since there's no Save on Delete action like on Forms? I guess set it up with a Bot?

Indeed, anything that you want to happen upon a delete must go through automation; that or setup a system where you flag the record for deletion, run you're action stack, then delete the record.

 - But yes, you've got the right idea: you can't do things after the delete

Thanks Matt,

They best way would be to make it so that I can mark the necessary records to be updated before the delete then run the quick update action after the deletion occurs.

Can't believe I haven't seen this post before. Very useful!

@MultiTech You are a maniac. Of the best kind! 😆

FYI Matt, quickupdates via bot is working without any problem for me (I mean via Scheduled Event, I don't need bots to do that, actions fired on row select and form save works fine for me), so I'd say it's stable and consistent enough

Same with me.  Bots are working fine. 

Just want to share also that I didn't have to add that [Update] column.
This is just because all my tables have a [Date_Modified] column that has Initial value of NOW() and set to "Reset on Edit".

So instead of firing Update = [Update]+1, I just call Date_Modified = NOW() and it gave me the same result.

True... but you lose the ability to see how many times a record has been edited

That data point, the [Update] column, has actually helped identify certain records in system in the past, where users were making tons of edits - which then helped us identify pain points that needed to be addressed.

  • When you see one record has 259 edits, vs. all the others with 4.... clearly something is going on... (^_^)

The [Update] column is a part of my Standard Starting Template, which also includes a TON of other metadata columns, all of which have evolved over time.  

As I was working on production-level apps, whenever I fell into a problem that I wish I would have had something in place to solve... I added a solution to that problem inside this auto-table;
  - this way whenever I fell into that hole again, I had something in place to prevent the fall

----------------------------------------------------------------------------------------------------

The beauty, and the curse, of the AppSheet platform....

3X_5_6_56613d1f4418869c74f8d5a988e2d003f083bafe.gif

Yep, I'm inclined to the [Update] column which I'm also adding to almost all of my tables.

@JPAlpano A use case where a date column is not enough is when you need to update a row more than just once a second, which is the minimum value you can get from NOW(). So, for example, when doing loops with actions, a NOW() value won't update the row fast enough, while we can add +1 hundreds of times in just 3-5 seconds (?)

Gotcha.  Thanks for the tip.  I never had this use case but this is something I will consider.

Hello, I'm new to Appsheet and I've been trying to figure this out.

Is it possible to use this system to update multiple tables at once from one update button?

Sure, but be carefull with the amount of rows. You may want to even move something like that to a bot, but even there if you have expensive calculations you wouldn't want to run it on more than 400-500 rows ~

Would you be able to provide information on how to do it? I've tried to figure it out but unfortunately have had no luck.
I made a post looking for assistance with what I was trying to do if you'd like to look.

People/Employee Directory - Google Cloud Community

I just happened to come across this and wanted to say thanks for the detailed explanation. I have been wondering though whether something like this could just be implemented by introduction of a 'force save' action, as in you add a child record to a parent record and when adding the child record there is an option of execute an action on a set of rows, choose the parent table, and for the reference action have a 'Save' row which would force all formulas to update. Just a thought, of course that is not yet available.

You can do that, it's quite common

Don't you still have to update something in the child rows though?

Top Labels in this Space