Detecting changed values to trigger AC/BC microflows

If I attach microflows to domain entities that are set to run Before or After Commit, is there any way to detect if the value in a field has been changed in the transaction. I have microflows that I want to trigger only if the value in a certain attribute has been changed. I want to add a simple initial split in the microflow that will exit if the value has not changed, but will run the rest of the microflow actions if the attribute value is changed. The only way I can see to do this now is to store the original attribute value in a duplicate field, then compare the values, and at the end of the process set the copy field to the current value. This is obviously not a good design as I have to duplicate attributes and create microflows to set the values to these duplicate fields. Is there any functionality to compare Database.Value and Transaction.Value of an attribute? Is there any other way to achieve this? Follow-up after answer: Does this technique only work for Before Commit microflows?
2 answers

Yes, you can retrieve the same object again from the database, and than compare its values with the values of the object being saved.


Try javacode?

if (myObject.getMember(getContext(), "MyMemberName").getState() == MemberState.CHANGED)
 Core.execute(getContext(), "MyMicroflow", myObject);

Followup answer: yes, like Michel said, only for before commits.