I have a datatable and use a button to create a new entity which is then added to the table.
So far, this works just fine.
Only when I add a function to initialize the new entity after creating it, saving the entity fails although the toast shows “success”.
So, I have a new entity standard action attached to the button plus the function call to the init-function which is a function of the respective entity.
If the init-function is called (debugger shows no problems), saving does not work.
if the init-function is not called, saving seems to work (feedback toast says success), but it doesn’t.
I would love to not use an init-function for trivial entities, but since the default value for a bool attribute is null instead of false which leads to further complications down the line, I need to initialize.
extends Entity
exposed function initEntity()->result: boolean
this.distrodate=currentDate()
this.completed=false
result= true
return result
Just to clarify, I tried previously with “return true” and I also tried to only assign the date, not the boolean value.
Interestingly enough, the initialization per se is working, it’s just that the save action does not work afterwards.
So here’s the interesting point: After writing this, instead of using the standard action, I created a function that saves the entity programmatically and voilá - that does the trick!
For your case, for the boolean thingy, you can try creating a boolean datasource and give it as initial value false, then copy it in your entity’s property, using that init button, perform your other actions and then save your final entity using another button.
Declaration of the datasource:
The “init entity” button has the init+copy actions: