Find a duplicate object comparing only not-empty values.

I have an object with multiple reference selectors. I need to create a microflow that would check the database to find is there any object with the same reference selector values selected (search for a duplicate). I could do it with a regular retrieve action and multiple XPath conditions, but the challenge is – if the reference selector is empty it should not be compared. So I’m looking for a duplicate only among not-empty reference selectors.   How can it be implemented? As I know if/else statements don’t work in XPath.    UPD I tried to compare it to empty, but I’m getting an error “Associations can’t be compared to empty”. Also, will this expression check if the association is not empty and is equals to current value (I need it)? Or it will check if it is not empty and not equals to the current value (I don’t need it)?
2 answers

In your xpath when retrieving entityB you could go for:

[$objectA/entityA_entityB != empty and module.entityA_entityB/module.entityA]


First retrieve all the referenced objects of the object you want to compare in the MF. 

So let's say you retrieved the referenced objects and stored these in variables $ReferenceSelectorVar1 and $ReferenceSelectorVar2. 

Then in xpath, use the retrieved variables like this:

[($ReferenceSelectorVar1 = empty or Object_Reference1 = $ReferenceSelectorVar1)
($ReferenceSelectorVar2 = empty or Object_Reference2 = $ReferenceSelectorVar2)] 

And so on!