Trying to compare if an object if the same in memory as in the databe

0
I’m trying to see if an object already exists in the database so I don’t add a duplicate. I created this microflow where I retrieve the entity from the database  And then check if they are the same, but I’m always getting true even when the object already exists
asked
2 answers
0

Enzel,

The conditions you use are checking to see if the objects are the same, not if they have change.

To see if they have changed, use the Java actions ObjectHasChanged and or MemberHasChanged.  These Java actions can be found in Community Commons.

Hope that helps,

Mike

answered
0

Hi Enzel,

Based on your first sentence what you are looking for is this:

Retrieve entity from database where

[id != $entity] //So another object of the same entity in your database (is your entity a singleton?)

In addition you might want to check some other attribute to conclude if this is a possible duplicate, so add an extra xpath constraint:

[attribute1 = $entity/attribute1]  //So this checks if you already have an object in database with something like same name, or ‘Active = true’ or whatever you would like to compare.

answered