Trying to delete corresponding data from a different Data Type

I have 3 data types; TblProducts is a list of my users Products, TblOutlets is a list of the Outlets each User owns and TblProductsOutlets tracks which Users are selling what Products for how much etc from each Outlet.

I have a Repeating Group which enables the logged in User to see only their own Outlets and then they can click an icon next to an Outlet that shows only the Products they’re selling from that Outlet. That works brilliantly thanks to invaluable here yesterday.

I now need an icon on the same Repeating Group row that enables the logged in User to delete a Product from a particular Outlet when they’re sold out. My trouble is that the Repeating Group is on a PopUp that has Type of Content = TblOutlet so when they go to Delete the Product at that Outlet currently they delete the whole Outlet from the App. I’ve tried changing the Type of Content to TblProductsOutlets but this doesn’t work. So my question is, if it’s possible, what do I need to do so my logged in users can Delete just an occurrence of a Product at a particular Outlet without deleting the Outlet?

Again, I’m hugely grateful to and in awe of anyone who can help me achieve this successfully.

Thank you.

Assuming that your ‘Outlet’ datatype has a list field of ‘products’ then all you need to do, when the icon is clicked, is remove the current cell’s product from the popup’s outlet.

So run a workflow to make changes to the popup’s outlet, and change the ‘products’ list field, by removing the current cell’s product.

If your database is set up the other way round (i.e. your products have a list of ‘outlets’ they are sold at), then make changes to the current cell’s product, and remove the popup’s outlet from that list.

Thank you for taking the trouble to reply to me.

My TblOutlet doesn’t have a “list of items” in Products because, possibly incorrectly, I figured that wouldn’t then enable the User to put extra details against each product. So if, for example, User A was selling a “Gold Widget A” for £2 from “Outlet A” and “Silver Widget A” for £1 from the same “Outlet A” then using the “list of items” option wouldn’t let me add the individual fields of colour, cost etc to each Product. (I accept, I’m likely to be wrong about this) so I created a TblProducts to log each variation of a Product as a new record. Is this what’s likely to be causing my issue now and should I change it?

Thanks again though for coming back to me. Everything helps the learning curve.

If a specific product (product A) can be sold at different outlets for different prices (e.g. product A : outlet 1 : £6, or product A : outlet 2 : £9), or has any other data specific to the product at that outlet, then you’re correct that having a separate datatype is needed (i.e. a product/outlet datatype that contains fields for Product, Outlet, and Price etc.).

If the price (or other details) of a product is the same at all outlets then there’s no need for a separate datatype (although it’s a perfectly valid approach still). There’s always more than one way to do things, so your database set up seems fine.

In any case, I assume your ‘TblProducts’ datatype has fields to connect it to both a ‘Product’ datatype and an ‘Outlet’ datatype.

And, presumably, the data source for your Product RG in you popup is a search for TblProducts (who’s Outlet is the popup’s outlet)'s products?

In that case you’ll want to delete a specific ‘TblProducts’ entry - so you’ll need to add a ‘delete a thing’ workflow action then, for the thing to delete, do a search for ‘TblProducts’ who’s product is the current cell’s product and who’s outlet is the popup’s outlet, then select the first item.

That will delete the TblProducts entry that connects the selected outlet to the current cell’s product.

Alternatively (a slightly simpler, and possibly better way), you could set the content type of the RG inside your popup to be TblProducts, and the data source to be a search for TblProducts who’s outlet is the popup’s outlet.

Then inside each cell you’ll ned to refer to the current cell’s TblProducts’s product (i.e. current cell’s TblProducts’s product’s name, or current cell’s TblProducts’s product’s description). Then to delete the TblProducts entry you can simply delete the current cell’s TblProducts.

Thank you. I think you’ve answered my question here. I’m just reading and digesting it and putting it all into practice. You’re right in your assumptions about my app with the appropriate links between datatypes.
I’m in awe of your knowledge and very grateful for your trouble and effort to help me. Thank you! I’m far more confident that I’ll get to where I need to be now.

1 Like

No problem, if you get stuck again or need more help, just ask - there are always plenty of people in the forum with knowledge to share who are willing to help :slight_smile: