Hi, I have Publication and WosCitationIndex (WSI) entities. There's a many-to-many relationship between the two entities. When creating an Publication object, I select WSI objects from the combobox (multiple selection dropdown menu) on the Publication page. When developing the API, I use a separate WSI entity in the message definition and export mapping sections. But also, I opened the association (WSI entity) to the API based on the Publication entity. Remember, I have thousands of Publication objects, but only 10 WSI objects in total. However, the team managing the data warehouse wants the data returned from the service to come as separate entities, not joined. That's why they need the key ID; otherwise, they can't perform any operations. My question is: how do I create the key ID / primary key in my API? Do I keep the id of the WSI object in an attribute of Publication object? And when I establish an association between multiple WSI objects and an Publication, how can I keep multiple IDs in this attribute?
asked
AYBERK AKBALIK
1 answers
0
Hi Ayberk,
In a many-to-many relationship, Mendix will not expose the association IDs automatically in the API payload. If the external system requires the ID values (instead of joined objects), then the best approach is to store the external key inside your domain model. For example, add an attribute like ExternalWSI_ID in the Publication_WSI association entity or directly in the WSI entity. During import/export mapping, you populate this attribute from the API response and then use it to reconnect the association relations in microflows. This way, you can keep multiple IDs, maintain the many-to-many mapping, and still return the exact ID list the API expects without exposing Mendix internal identifiers.