Log In    |    Knowledge Base    |    4D Home
Tech Tip: Entity class function pitfall in client/server
PRODUCT: 4D Server | VERSION: 19 | PLATFORM: Mac & Win
Published On: May 15, 2023

When working with entity class functions in client/server, remember that they are executed on the server, by default. This means that if the function is intended to modify the current entity on the client, the keyword “local” must be used. Otherwise, client-side entities will not be able to use the entity class function.

For example, let’s say there is a Documents DataClass with an Entity Class function that initializes some properties for new Documents entities:

// DocumentsEntity

Class extends Entity

Function initProps"Amy Lee"
  This.pubDate:=Current date

And the following method creates a new Documents entity, calls the above entity class function, and saves the entity:


When the method is ran in standalone, the new entity’s properties are initialized properly. However, in client/server, the properties are not initialized at all.

This is because the “local” keyword needs to be added to the front of the entity class function like so:

local Function initProps

Only then will entities on the client will be able to call the initProps function.