Updating Parent Table after Child Table has a record deleted

Hello, I have the following tables:

table A (Parent Table): Department
table B (Child Table): Users

table A has a column: # of Users which is a formula: Sum of all the User records that belong to that specific Department.

My question is: How can I tell Appsheet to recalculate the formula for # of Users when a register from the Child Table gets deleted?

I’ve tried to build this using Google Apps Script but sadly I cannot catch the record’s info from the Child Table when the action is a delete action.

Thanks

Is your column #number of users a Virtual column calculated in Appsheet or is it a formula column calculated in your spreadsheet?

If your tables are set up correctly in Appsheet and you created a Ref from your Users table to your Department table then your departments table will have an automatic field added by Appsheet called something like

Related Users

This will be of type List

You should construct a new Virtual column on your departments table with the formula

Count([Related Users])

This will update in real-time as you add and delete records from your Users table.