Synchronization Editor: Key resolution - Dynamically filtering schema type based on target system property. Such as DialogState

Hello OneID people,

I've stumbled across a pickle that I was able to work around for now, but I would like your opinion on how I might be able to solve it permanently.

I have a sync project which, among others, imports locations from the source system. This includes the properties such as Country Code, State, Zip Code and Street Address.

During the sync, IAM reports that it could not set the value of UID_DialogState for a number of locations, because the value for the State "NY" is not unique. Hang on... "NY = New York" is not unique? To my surprise when one filters DialogState entries with ShortName = 'NY' then 6 results are shown. Mind blown.

To my luck, I know for a fact that this source system only delivers locations in USA and Canada. So the work around was simple.

I create two key resolution properties on UID_DialogState. One which is filtered to only return states within USA and one to only return states within Canada.

I then map the two virtual properties to Right.State. One which is only active when Right.Country = 'USA' and the other only active when Right.Country = 'CAN' 

Works a charm.

But a problem would arise if the source system were to deliver locations from a number of different countries. The work around described above would become unfeasable.

So the question is: How can one dynamically filter the results of a key resolution property? Is there a way to set the filtering condition of a key resolution to point to a target system property?

In my example, the filtering condition for the key resolution would look like: UID_DialogCountry IN (SELECT UID_DialogCountry FROM DialogCountry WHERE Iso3166_3 = '$Right.Country$')

Thanks in advance for your time and help!