Determine if property was changed?

0
I want to detect wether a property of an object was changed. I have the object "Issue". It contains a column "Status" of type Enumeration. When the user changes the status, I want to send a notification. Therefore I have to somehow determine wether the status was changed or not. I can't always send the notification, since the user should not get a notification when the status wasn't changed. I looked at the events on the objects. There's an after commit and a before commit. However, I think I can't use those events because: Before commit: I can fetch the current record from the database and compare the status with the new record's status. However, at that point I have no guarantee the object will be committed correctly, since that microflow is only called before committing the object. After commit: I have no way to find out what the previous status was, so I can't determine that the status actually changed.
asked
2 answers
1

Could you not use the community commons getOriginalValueAsString?

Returns the original value of an object member, that is, the last committed value.

This is useful if you want to compare the actual value with the last stored value. - item : the object of which you want to inspect a member - member: the member to retrieve the previous value from. Note that for references, the module name needs to be included.

If you do a before commit and check if the status are different you can then send the mail.

Regards,

Ronald

answered
0

You can introduce a boolean [StatusChanged] that is set when before commit finds a difference.

If the beforecommit fails this change is also rolled back and if the before commit succeeds after commit you send the notification and clear the [StatusChanged] boolean.

answered