Multiple entities with the same key
Question

We have entities in our data with the same value in SS_Key field. The reason is probably in that long time ago entity B was created as a clone of entity A. This creates a problem when we use EntityChangeHistory component. It looks up the entity by this key, because the reference field (EntityId) has it as part of Type field. EntityChangeHistory logic has no way to understand which of the two entities to use.

So I have some questions:

1. How does service studio know that the referenced entity is actually B and not A? Because it shows it correctly as "B identifier" everywhere.

2. Is there any way to find this out in my code?

3. If I run the SQL to update this value with my own generated value and update all references similarly - will it work?

4. Is there any other or intended way to fix this? The only thing which comes to my mind is to re-create those entities and migrate all data to the new ones.

Hi Igor,

I assume that EntityChangeHistory is a component you wrote yourself to keep a history of entity changes?

When you realize that the SS_Key is not a unique identifier for the Entity entity (or any other entity for that matter) you probably have only one option and that is accept some Technical Debt. You obviously need a composite key (add Espace_Id I would assume) to make this work.

I would strongly advise against tampering the contents of your system entities!

Cheers, Toine.

Hi Toine,

No we took this component from Forge many years ago, I think it was this one: https://www.outsystems.com/forge/component-overview/374/human-readable-change-history

I'm naming it EntityChangeHistory because this is the name of the module. But I did already fixes there, so you can say it's customized version.

But thanks for the hint regarding eSpaceId, this looks like a good solution if I add it as a parameter!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.