Renaming product categories and keeping products in sync - Editing item creates duplication

Hi there!

I have a use case where a business can add a product category and then assign products to it. For example, the business can create a category called “Shoes” and then add a product called “Nike Airs” to that category. This is currently working, but if the business wants to change the name of the category, for example from “Shoes” to “Footwear,” I am having trouble updating the products that were assigned to the “Shoes” category to match the new name “Footwear.”

Currently, when I try to edit the name of a category that has products assigned to it, it creates a new category with the new name instead of updating the existing one. This happens even when I use the Edit action. Additionally, if I try to edit the original category again after it has created a second one, it weirdly works and doesn’t create another category.

Image 1 - The page users can add categories and products:

Image 2 - Creating the product category ‘Shoes’:

Image 3 - Creating the product ‘Nike Air’ and assigning to the ‘Shoes’ category:’

Image 4 - Success, the category and product all display correctly:

Image 5 - Issue! When the user renames the ‘Shoes’ category (using Edit action) to ‘Footwear’, it creates a new category instead of updating the exisiting one’s name. The Nike Air’s product category also doesn’t update to the new name:

Image 6 - What the table looks like after following the steps above:

Appreciative of any help!

Looks like you are storing Categories and Products in the same table…and also sourcing your choice component from that same category row. When you edit a Product category, you are only updating one row, so you end up changing the first row, but the second row remains untouched, so now you have a footware AND shoe category to choose from.

I would restructure your data. First I would have separate tables for Categories and Products. This will allow you to edit categories in their own table, and each category will be listed once instead multiple times due to being mixed with Products. Make sure you have a RowID column in the category table

Second, when creating product rows, I would change the choice component to store the category RowID Value, but Display As the category name. The fact that you are changing a category name is the sole reason why you should always store the associated ID instead. Names can change. ID’s won’t. Then in your products table, you just need a relation/lookup to retrieve the category name from it’s respective ID.


@Jeff_Hager Wow… I literally spent days trying all sorts of things and you solved it straight away! Thank you so much, such a simple and clean solution. Really appreciate it!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.