Setting a value in onInit()

Hello CUBA community,

Just a quick question to better understand the platform.

I don’t seem to be able to set a value for an entity field directly in onInit(InitEvent event). I’m curious why this isn’t working for me, particularly because it is used in the following example:

Is there a step that I’m missing?

Thanks in advance!

Did you try the following?

public void onBeforeShow(BeforeShowEvent event) {

Hello @mortozakhan,

Yes, I can get it working that way. The problem is that I’m trying to get it to function directly from the initialization of a NEW entity object only, not one that already exists. Since I saw that is used in the example I provided, I was wondering why using setValueI() doesn’t seem to work in onInit() when I try it.


Hi @adam5sbass,
You should use InitEntityEvent instead of InitEvent:


In the mentioned example, it is not the entity that is being initialized but a component.


1 Like

Thank you for the clarification! I appreciate it.

1 Like