dynamic count from other table, in table view

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
dge
Posts: 25
Joined: 2013-12-05 02:54

dynamic count from other table, in table view

Post by dge » 2013-12-05 03:12

I'm trying to display a dynamic count (generated on the fly) in a table view, and can't figure out how to do it. I have an orders table with various items, and also a serial numbers table. I would like to display a count in the orders table of how many units in the serial numbers table are present for that item. In other words, if the orders table has 3 items, SKU 1, 2 and 3, show how many units in the serial number table are assigned to this order_item already (ie. "shipped").
I want to see whether all items have been shipped or if some have been overlooked.

I know I could simply make a database entry of the count, but because it's possible to change things in the serial numbers table manually, or to "return" the item using other code, I don't want to have to maintain an update of a database entry. I would much rather do this by a dynamic count when the table is displayed.

At first it seemed the way to do this is was the tablename_init area of the hook, but I don't have access to the $data variable there, so I can't form the queries properly. If I do it in tablename_before(after)_insert(update) etc., I'm making database entries and updates so that's not what I want either. Seems it should not be difficult to count records and display the count in a column without entering the count in the database, but I can't figure how to do it!
Thanks for you assistance
David

Post Reply