You can do it with a search and a custom field that references the search.
Create search that does a count of the items in the subtab. Make sure to set transaction as an "Available Filter" and make the search public. the Available Filter is what ties the filtered search results to your transaction.
Create custom body field to reference the search result. Uncheck the "Store Value" checkbox - you don't want to store the data - you want to reference the saved search instead. Under the Validation and Default tab, choose the saved search from step 1.
No code required.