According to the user guide I understand we can get the oldValue of an attribute before commitListener as follows:
event.getChanges().getOldValue("approved")
How can we get any attribute value (current) of the same attribute before commit from Entity Listener?
I tried this but it still shows old value: event.getChanges() getValue("approved")
krivopustov
(Konstantin Krivopustov)
September 27, 2022, 1:01pm
2
You can load the entity instance and get the current values of its attributes. It is shown in the examples of the docs.
Hi Konstantin
Thanks for your comments. I tried it already, please see below my code and the status of the field value:
Loaded the entity
When I changed the status of the field value (here it’s “approved”)= true from my screen and save the entity, it triggers the event Listener but the entity I load still shows the status of field “approved”, it still shows approved = false:
Is there anything wrong in my code?
krivopustov
(Konstantin Krivopustov)
September 29, 2022, 1:55pm
4
I don’t see anything wrong.
The AttributeChanges object contains previous (old) state of the changed attributes.
Yes, that’s right but what I need is new state before commit.
krivopustov
(Konstantin Krivopustov)
September 29, 2022, 2:45pm
6
The new state is in journal.getApproved().
Yes, that’s what I tried as you can see the images shared, but I get the value = false, while I actually have selected (true).
krivopustov
(Konstantin Krivopustov)
September 30, 2022, 9:27am
8
Perhaps some code changes the value after you set it to true.
Try to just set a breakpoint to the setter and see when it’s changed.