KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Return the Number of Entities in a Dataclass with .getCount()
PRODUCT: 4D | VERSION: 19 R 5 | PLATFORM: Mac & Win
Published On: April 24, 2023

As of 4D v19 R5, it's possible to use the .getCount() function to return the number of entities in a Dataclass.
All Dataclasses in a 4D application are available as a property of the (ds) datastore.

Example:



var $ds : 4D.DataStoreImplementation
var $countPersons; $countContacts: Integer

$ds:=Open datastore(New object("hostname"; "www.myserver.com"); "myDS")
$countPersons:=$ds.Persons.getCount()   // remote datastore


$countContacts:=ds.Contacts.getCount()   // main datastore


Note:
If this function is used within a transaction, entities created during this transaction will be taken into account.