Forum Academy Marketplace Showcase Pricing Features

Copying Data from 2 datatables

Hi, Im trying to figure out how to copy a 2 linked lists of datatypes and not repeat items.

ITEMS
Name (text)
Location (location)

LOCATION
Name (text)

I would like to select which ITEMS I want to duplicate, then press a button to make a copy of a list of ITEMS and also copy of the list of LOCATIONS. The new ITEM should then assign itself to the new LOCATION as per the original. However, I only want one duplicate of LOCATION even though multiple ITEMS point to the same LOCATION.

My issue is that currently my app creates a new LOCATION for every ITEM I duplicate. So in essence if there were 5 ITEMS with the same LOCATION, I now have 5 ITEMS, which is correct and 5 copies of the same LOCATION, which is wrong. I want just one copy of LOCATION and 5 individual ITEMS that are assigned to that LOCATION