KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: ORDA dataClass.new() primary key calculated after save in client-server
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: February 5, 2020

ORDA makes it easy to create a new entity for a corresponding table by simply using dataClass.new(). In standalone, the primary key is automatically assigned to that entity. However, in client-server, the pimary key is not calculated until the entity is saved on the server.

For example, in standalone, suppose that we have this following line of code to create a new entity:

$entity:=ds.Table_1.new()

In the debugger, we can see that the entity has been assigned a primary key (ID of 4):



However, if we inspect the same entity in client-server, we can see that the primary key is not assigned yet (ID of null):



That is because in client-server, if the primary key of the corresponding table is auto-incremented, it will be calculated when the entity is saved on the server. We can see that, after saving it, the primary key is generated for the entity: