Intended method for getting entity changes?

Hi Cuba Support,

What is the intended way of using the EntityChangeListener to get the changes that have been made to an Entity?

I am trying to create something similar to Entity Log for one Entity.

TimeStamp | ChangedBy | ChangeType | Entity | Change Made to Entity

But I am going to make the changes into a simple string sentence - for example:

“Asset reference was changed to: ___”
“Asset was assigned to ___”

Here is what I have right now (it is obviously incomplete and would have one attribute change per line)

for(int i=0; i<changes.getAttributes().size();i++){
                if (changes.isChanged(arrayList.get(i))) {
                    String oldValue = changes.getOldValue(arrayList.get(i));
                    sb.append(arrayList.get(1));
                    sb.append(" changed from: ");
                    sb.append(oldValue);
                    sb.append(" to:");
                    assetTransactionLog.setChanges(sb.toString());
                }
            }

How do you get the after change attribute value?

I would just like to know how to get each change before and after to put into the table.

Thank you

Regards

Matt

Hi!
It seems that you may use our entity snapshots mechanism. See the documentation along with example here.

Hi Natalia,

Thank you I shall give that a look into :slight_smile:

Regards

Matt